summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPawel Hajdan, Jr <phajdan.jr@gentoo.org>2011-10-13 23:58:45 +0200
committerPawel Hajdan, Jr <phajdan.jr@gentoo.org>2011-10-13 23:58:45 +0200
commitcb1eac2e87e24b35de97afff8e6332eacccb57e5 (patch)
treebf56dd1264e851b037383e1e004348aa922dc687 /bugzilla-viewer.py
parentUpdate Bugzilla when stabilizing packages. (diff)
downloadarch-tools-cb1eac2e87e24b35de97afff8e6332eacccb57e5.tar.gz
arch-tools-cb1eac2e87e24b35de97afff8e6332eacccb57e5.tar.bz2
arch-tools-cb1eac2e87e24b35de97afff8e6332eacccb57e5.zip
Fix a crash when dependent bug is not accessible.
Diffstat (limited to 'bugzilla-viewer.py')
-rwxr-xr-xbugzilla-viewer.py26
1 files changed, 19 insertions, 7 deletions
diff --git a/bugzilla-viewer.py b/bugzilla-viewer.py
index 0891979..c45530a 100755
--- a/bugzilla-viewer.py
+++ b/bugzilla-viewer.py
@@ -29,12 +29,19 @@ class TermTooSmall(Exception):
pass
class Bug:
- def __init__(self, xml):
- self.__id = int(xml.find("bug_id").text)
- self.__summary = xml.find("short_desc").text
- self.__status = xml.find("bug_status").text
- self.__depends_on = [int(dep.text) for dep in xml.findall("dependson")]
- self.__comments = [c.find("who").text + "\n" + c.find("thetext").text for c in xml.findall("long_desc")]
+ def __init__(self, xml=None, id_number=None, summary=None, status=None):
+ if xml is not None:
+ self.__id = int(xml.find("bug_id").text)
+ self.__summary = xml.find("short_desc").text
+ self.__status = xml.find("bug_status").text
+ self.__depends_on = [int(dep.text) for dep in xml.findall("dependson")]
+ self.__comments = [c.find("who").text + "\n" + c.find("thetext").text for c in xml.findall("long_desc")]
+ if id_number is not None:
+ self.__id = id_number
+ if summary is not None:
+ self.__summary = summary
+ if status is not None:
+ self.__status = status
self.__cpvs_detected = False
self.__cpvs = []
@@ -118,6 +125,11 @@ class MainWindow:
self.add_bug_to_queue()
c = self.screen.getch()
+
+ def bug_for_id(self, bug_id):
+ if bug_id in self.bugs_dict:
+ return self.bugs_dict[bug_id]
+ return Bug(id_number=bug_id, summary='(summary unavailable)', status='UNKNOWN')
def init_screen(self):
(self.height, self.width) = self.screen.getmaxyx()
@@ -188,7 +200,7 @@ class MainWindow:
output += textwrap.wrap("Press 'a' to add them to the stabilization queue.", width=width-2)
output.append("-" * (width - 2))
- deps = [self.bugs_dict[dep_id] for dep_id in bug.depends_on()]
+ deps = [self.bug_for_id(dep_id) for dep_id in bug.depends_on()]
if deps:
output += textwrap.wrap("Depends on:", width=width-2)
for dep in deps: