wcs: don't crash manager getting list of options when down (#25423)
This commit is contained in:
parent
e626b0b6b3
commit
15959ea28d
|
@ -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')
|
||||
|
|
Loading…
Reference in New Issue