wcs: don't crash manager getting list of options when down (#25423)

This commit is contained in:
Frédéric Péters 2018-10-23 14:11:58 +02:00
parent e626b0b6b3
commit 15959ea28d
1 changed files with 8 additions and 2 deletions

View File

@ -27,8 +27,12 @@ def get_wcs_services():
return settings.KNOWN_SERVICES.get('wcs')
def get_wcs_json(wcs_site, path):
return requests.get(path, remote_service=wcs_site, without_user=True,
headers={'accept': 'application/json'}).json()
response = requests.get(path, remote_service=wcs_site, without_user=True,
headers={'accept': 'application/json'})
if response.status_code != 200:
# the exact error will have been logged during request.
return {}
return response.json()
def get_wcs_options(url, include_category_slug=False):
references = []
@ -39,6 +43,8 @@ def get_wcs_options(url, include_category_slug=False):
if response_json.get('err') == 1:
continue
response_json = response_json.get('data')
if not response_json:
continue
for element in response_json:
slug = element.get('slug')
title = element.get('title')