From 16addfa5ff63632bbff7ac734909dbf3fbe203fe Mon Sep 17 00:00:00 2001 From: Michael Bienia Date: Tue, 23 Feb 2010 00:33:13 +0100 Subject: [PATCH] lp-set-dup: Don't crash when accessing private bugs (lp: #525539) --- debian/changelog | 3 ++- lp-set-dup | 23 ++++++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/debian/changelog b/debian/changelog index 18a72e3..024635f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -30,12 +30,13 @@ ubuntu-dev-tools (0.93) UNRELEASED; urgency=low * Add support for the other LP service roots (edge is still default) * Depend on python-launchpadlib >= 1.5.4 * Also check package sets for upload permissions. + * lp-set-dup: Don't crash when accessing private bugs (lp: #525539) [ Michael Vogt ] * edit-patch: add wrapper around cdbs-edit-patch, dpatch-edit-patch, quilt to transparently deal with the various patch systems. - -- Michael Bienia Sat, 20 Feb 2010 18:38:17 +0100 + -- Michael Bienia Tue, 23 Feb 2010 00:31:19 +0100 ubuntu-dev-tools (0.92) lucid; urgency=low diff --git a/lp-set-dup b/lp-set-dup index 50ace11..63bb54f 100755 --- a/lp-set-dup +++ b/lp-set-dup @@ -22,10 +22,12 @@ # Authors: # Loïc Minier -import os, sys +import sys + from optparse import OptionParser import ubuntutools.lp.libsupport as lp_libsupport +from launchpadlib.errors import HTTPError def die(message): print >> sys.stderr, "Fatal: " + message @@ -56,7 +58,14 @@ if __name__ == '__main__': die("Couldn't setup Launchpad for the ubuntu-dev-tools consumer; %s" % (suggestion, )) # check that the new main bug isn't a duplicate - new_main_bug = launchpad.bugs[args[0]] + try: + new_main_bug = launchpad.bugs[args[0]] + except HTTPError, error: + if error.response.status == 401: + print >> sys.stderr, "E: Don't have enough permissions to access bug %s" % (args[0]) + die(error.content) + else: + raise new_main_dup_of = new_main_bug.duplicate_of if new_main_dup_of is not None: s = None @@ -72,7 +81,15 @@ if __name__ == '__main__': bugs_to_process = [] for b in args[1:]: print "Processing %s" % (b) - bug = launchpad.bugs[b] + try: + bug = launchpad.bugs[b] + except HTTPError, error: + if error.response.status == 401: + print >> sys.stderr, "W: Don't have enough permissions to access bug %s" % (b) + print >> sys.stderr, "W: %s" % (error.content) + continue + else: + raise dups = bug.duplicates if dups is not None: bugs_to_process.extend(dups)