misc: add support for REQUEST_PROXIES settings (#20385)

This commit is contained in:
Frédéric Péters 2017-12-02 19:00:16 +01:00
parent a51fb45aa4
commit aa56564aa0
2 changed files with 6 additions and 1 deletions

View File

@ -19,6 +19,7 @@ import datetime
import requests
import vobject
from django.conf import settings
from django.contrib.auth.models import Group
from django.core.exceptions import ValidationError
from django.core.urlresolvers import reverse
@ -426,7 +427,7 @@ class Desk(models.Model):
def create_timeperiod_exceptions_from_remote_ics(self, url):
try:
response = requests.get(url)
response = requests.get(url, proxies=settings.REQUESTS_PROXIES)
response.raise_for_status()
except requests.HTTPError as e:
raise ICSError(_('Failed to retrieve remote calendar (HTTP error %s).') % e.response.status_code)

View File

@ -145,6 +145,10 @@ MELLON_USERNAME_TEMPLATE = '{attributes[name_id_content]}'
MELLON_IDENTITY_PROVIDERS = []
# proxies argument passed to all python-request methods
# (see http://docs.python-requests.org/en/master/user/advanced/#proxies)
REQUESTS_PROXIES = None
local_settings_file = os.environ.get('CHRONO_SETTINGS_FILE',
os.path.join(os.path.dirname(__file__), 'local_settings.py'))
if os.path.exists(local_settings_file):