From 1a3150b1430a775848b8e74acd829cd7e4f7fddd Mon Sep 17 00:00:00 2001 From: Shalini Roy Date: Jan 12 2016 21:43:39 +0000 Subject: Handling response in data method in updates2stable --- diff --git a/hubs/widgets/workflow/updates2stable.py b/hubs/widgets/workflow/updates2stable.py index 1a27be6..0ee6c90 100644 --- a/hubs/widgets/workflow/updates2stable.py +++ b/hubs/widgets/workflow/updates2stable.py @@ -53,26 +53,30 @@ def data(session, widget, username): url = bodhiurl + query headers = {'Accept': 'application/json'} response = requests.get(url, headers=headers) - data = response.json() - - # Limit it this to only the updates that haven't already requested stable - # but which can actually be pushed to stable now. - data['updates'] = [ - update for update in data['updates'] - if update['request'] is None and - any([giveaway in comment['text'] for comment in update['comments']]) - ] - - # Stuff some useful information in there. - baseurl = 'https://apps.fedoraproject.org/packages/images/icons/' - for update in data['updates']: - build = update['builds'][0] - nvr = build['nvr'] - package = parse_nvr(nvr) - update['icon'] = baseurl + package[0] + '.png' - update['link'] = bodhiurl + update['title'] - - return data + if response.status_code == 200: + data = response.json() + + # Limit it this to only the updates that haven't already requested stable + # but which can actually be pushed to stable now. + data['updates'] = [ + update for update in data['updates'] + if update['request'] is None and + any([giveaway in comment['text'] for comment in update['comments']]) + ] + + # Stuff some useful information in there. + baseurl = 'https://apps.fedoraproject.org/packages/images/icons/' + for update in data['updates']: + build = update['builds'][0] + nvr = build['nvr'] + package = parse_nvr(nvr) + update['icon'] = baseurl + package[0] + '.png' + update['link'] = bodhiurl + update['title'] + + return data + else: + data = {} + return data def parse_nvr(nvr):