Projet

Général

Profil

0001-wcs-don-t-crash-manager-getting-list-of-options-when.patch

Frédéric Péters, 23 octobre 2018 14:12

Télécharger (1,5 ko)

Voir les différences:

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

 combo/apps/wcs/utils.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
combo/apps/wcs/utils.py
27 27
    return settings.KNOWN_SERVICES.get('wcs')
28 28

  
29 29
def get_wcs_json(wcs_site, path):
30
    return requests.get(path, remote_service=wcs_site, without_user=True,
31
            headers={'accept': 'application/json'}).json()
30
    response = requests.get(path, remote_service=wcs_site, without_user=True,
31
            headers={'accept': 'application/json'})
32
    if response.status_code != 200:
33
        # the exact error will have been logged during request.
34
        return {}
35
    return response.json()
32 36

  
33 37
def get_wcs_options(url, include_category_slug=False):
34 38
    references = []
......
39 43
            if response_json.get('err') == 1:
40 44
                continue
41 45
            response_json = response_json.get('data')
46
        if not response_json:
47
            continue
42 48
        for element in response_json:
43 49
            slug = element.get('slug')
44 50
            title = element.get('title')
45
-