Projet

Général

Profil

« Précédent | Suivant » 

Révision 5b445c72

Ajouté par Serghei Mihai il y a plus de 6 ans

misc: add support for REQUEST_PROXIES (#20378)

Voir les différences:

corbo/models.py
42 42
        super(Category, self).save(*args, **kwargs)
43 43
        if not self.rss_feed_url:
44 44
            return
45
        feed_response = requests.get(self.rss_feed_url)
45
        feed_response = requests.get(self.rss_feed_url, proxies=settings.REQUESTS_PROXIES)
46 46
        if feed_response.ok:
47 47
            content = feedparser.parse(feed_response.content)
48 48
            for entry in content.get('entries', []):
......
81 81
                if img.attrib['src'].startswith('/'):
82 82
                    continue
83 83
                image_name = os.path.basename(img.attrib['src'])
84
                r = requests.get(img.attrib['src'])
84
                r = requests.get(img.attrib['src'], proxies=settings.REQUESTS_PROXIES)
85 85
                if not r.ok:
86 86
                    continue
87 87
                new_content = r.content
corbo/settings.py
168 168
# sms expeditor
169 169
SMS_EXPEDITOR = 'Corbo'
170 170

  
171
# proxies argument passed to all python-request methods
172
# (see http://docs.python-requests.org/en/master/user/advanced/#proxies)
173
REQUESTS_PROXIES = None
174

  
175

  
171 176
local_settings_file = os.environ.get('CORBO_SETTINGS_FILE',
172 177
        os.path.join(os.path.dirname(__file__), 'local_settings.py'))
173 178
if os.path.exists(local_settings_file):
corbo/utils.py
89 89
                'message': etree.tostring(html_content, method='text'),
90 90
                'from': settings.SMS_EXPEDITOR}
91 91
        try:
92
            response = requests.post(settings.SMS_GATEWAY_URL, json=data)
92
            response = requests.post(settings.SMS_GATEWAY_URL, json=data, proxies=settings.REQUESTS_PROXIES)
93 93
            response.raise_for_status()
94 94
            if not response.json()['err']:
95 95
                # if no error returned by SMS gateway presume the that content

Formats disponibles : Unified diff