From 5448add7543c25dbde41435b59bbb9b226ae6a38 Mon Sep 17 00:00:00 2001 From: Michael Bienia Date: Sat, 22 Aug 2009 17:39:38 +0200 Subject: [PATCH] requestsync: make a "mail" and "lp" version of checkExistingReports and move it to the correct module --- requestsync | 50 --------------------------------- ubuntutools/requestsync/lp.py | 21 ++++++++++++++ ubuntutools/requestsync/mail.py | 14 ++++++++- 3 files changed, 34 insertions(+), 51 deletions(-) diff --git a/requestsync b/requestsync index 87ee6c8..125e19f 100755 --- a/requestsync +++ b/requestsync @@ -43,56 +43,6 @@ from ubuntutools.requestsync.mail import * from ubuntutools.requestsync.common import * from ubuntutools.requestsync.lp import postBug -def checkExistingReports(package): - """ Check existing bug reports on Launchpad for a possible sync request. - - If found ask for confirmation on filing a request. - """ - - launchpad = None - - try: - launchpad = Launchpad.login() - except ImportError: - print >> sys.stderr, 'Importing launchpadlib failed. Is ' \ - 'python-launchpadlib installed?' - except IOError, msg: - # No credentials found. - print msg - - # Failed to get Launchpad credentials. - if launchpad is None: - print >> sys.stderr, "Skipping existing report check, you should "\ - "manually see if there are any at:" - print "- https://bugs.launchpad.net/ubuntu/+source/%s" % package - print "" - return False - - # Fetch the package's bug list from Launchpad. - pkg = Distribution('ubuntu').getSourcePackage(name=package) - pkgBugList = pkg.searchTasks() - - # Search bug list for other sync requests. - matchingBugs = [bug for bug in pkgBugList - if "Sync %s" % package in bug.title - or "Please sync %s" % package in bug.title] - - if len(matchingBugs) == 0: - return # No sync bugs found. - - print "The following bugs could be possible duplicate sync bug(s) on Launchpad:" - - for bug in matchingBugs: - print " *", bug.title - print " -", lp_libsupport.translate_api_web(bug.self_link) - - print "Please check the above URLs to verify this before filing a " \ - "possible duplicate report." - print "Press Ctrl-C to stop filing the bug report now, otherwise " \ - "please press enter." - raw_input_exit_on_ctrlc() - - # # entry point # diff --git a/ubuntutools/requestsync/lp.py b/ubuntutools/requestsync/lp.py index c8cf5ff..5d14ade 100644 --- a/ubuntutools/requestsync/lp.py +++ b/ubuntutools/requestsync/lp.py @@ -59,6 +59,27 @@ team.''' return need_sponsor +def checkExistingReports(srcpkg): + ''' + Check existing bug reports on Launchpad for a possible sync request. + + If found ask for confirmation on filing a request. + ''' + + # Fetch the package's bug list from Launchpad + pkg = Distribution('ubuntu').getSourcePackage(name = srcpkg.getPackageName()) + pkgBugList = pkg.getBugTasks() + + # Search bug list for other sync requests. + for bug in pkgBugList: + # check for Sync or sync and the package name + if 'ync %s' % package in bug.title: + print 'The following bug could be a possible duplicate sync bug on Launchpad:' + print ' * Bug #%i: %s (%s)' % \ + (bug.id, bug.title, translate_api_web(bug.self_link)) + print 'Please check the above URL to verify this before continuing.' + raw_input_exit_on_ctrlc('Press [Enter] to continue or [Ctrl-C] to abort. ') + def postBug(srcpkg, subscribe, status, bugtitle, bugtext): ''' Use the LP API to file the sync request. diff --git a/ubuntutools/requestsync/mail.py b/ubuntutools/requestsync/mail.py index 1e00081..3475ba2 100644 --- a/ubuntutools/requestsync/mail.py +++ b/ubuntutools/requestsync/mail.py @@ -27,7 +27,12 @@ import socket from .common import raw_input_exit_on_ctrlc from ..lp.udtexceptions import PackageNotFoundException -__all__ = ['getDebianSrcPkg', 'getUbuntuSrcPkg'] +__all__ = [ + 'getDebianSrcPkg', + 'getUbuntuSrcPkg', + 'getEmailAddress', + 'postBug', + ] class SourcePackagePublishingHistory(object): ''' @@ -114,6 +119,13 @@ def needSponsorship(name, component): else: print 'Invalid answer' +def checkExistingReports(srcpkg): + ''' + Point the user to the URL to manually check for duplicate bug reports. + ''' + print 'Please check on https://bugs.launchpad.net/ubuntu/+source/%s/+bugs for duplicate sync requests before continuing.' + raw_input_exit_on_ctrlc('Press [Enter] to continue or [Ctrl-C] to abort. ') + def mailBug(srcpkg, subscribe, status, bugtitle, bugtext, keyid = None): ''' Submit the sync request per email.