From 3a7e95de4730460d3a1488d2d35129f2772a68c4 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Tue, 18 Nov 2014 14:51:58 -0500 Subject: [PATCH] handle possible private bugs in the graph Apparently people are marking public openstack bugs private some times. In these cases we have to handle the possibility that looking for the bug returns a keyerror, and move on gracefully. Change-Id: Icc30843bcc9cfc6822dc7791959c1d2b45765e01 --- elastic_recheck/cmd/graph.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/elastic_recheck/cmd/graph.py b/elastic_recheck/cmd/graph.py index 10a45a43..026a004b 100755 --- a/elastic_recheck/cmd/graph.py +++ b/elastic_recheck/cmd/graph.py @@ -39,13 +39,18 @@ def get_launchpad_bug(bug): lp = launchpad.Launchpad.login_anonymously('grabbing bugs', 'production', LPCACHEDIR) - lp_bug = lp.bugs[bug] - bugdata = {'name': lp_bug.title} - projects = ", ".join(map(lambda x: "(%s - %s)" % - (x.bug_target_name, x.status), - lp_bug.bug_tasks)) - bugdata['affects'] = projects - bugdata['reviews'] = get_open_reviews(bug) + try: + lp_bug = lp.bugs[bug] + bugdata = {'name': lp_bug.title} + projects = ", ".join(map(lambda x: "(%s - %s)" % + (x.bug_target_name, x.status), + lp_bug.bug_tasks)) + bugdata['affects'] = projects + bugdata['reviews'] = get_open_reviews(bug) + except KeyError: + # if someone makes a bug private, we lose access to it. + bugdata = dict(name='Unknown (Private Bug)', + affects='Unknown (Private Bug)', reviews=[]) return bugdata