From ac2641445913aedda8c5fb6726d131f9d41d0a75 Mon Sep 17 00:00:00 2001 From: Jonathan Davies Date: Fri, 2 Jan 2009 00:17:49 +0000 Subject: [PATCH] * requestsync: - Use optparse instead of getopt for option parsing. - Skip existing bug report check if python-launchpad-bugs is not installed. --- debian/changelog | 4 ++ requestsync | 108 +++++++++++++++++++++++++++-------------------- 2 files changed, 66 insertions(+), 46 deletions(-) diff --git a/debian/changelog b/debian/changelog index 3b7dd48..eb32110 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,10 @@ ubuntu-dev-tools (0.51) UNRELEASED; urgency=low * buildd: Added checks for arch-indep packages and packages which have no builds in a release. * hugdaylist: String improvements. + * requestsync: + - Use optparse instead of getopt for option parsing. + - Skip existing bug report check if python-launchpad-bugs is not + installed. -- Jonathan Davies Tue, 30 Dec 2008 15:51:55 +0000 diff --git a/requestsync b/requestsync index 07ed972..6340976 100755 --- a/requestsync +++ b/requestsync @@ -25,7 +25,7 @@ # # ################################################################## -import getopt +#import getopt import os import subprocess import sys @@ -33,6 +33,8 @@ import urllib import urllib2 from debian_bundle.changelog import Version +from optparse import OptionParser + # Use functions from ubuntu-dev-tools to create Launchpad cookie file. sys.path.append('/usr/share/ubuntu-dev-tools/') import common @@ -76,6 +78,8 @@ def checkNeedsSponsorship(component): print "If the above is correct please press Enter, otherwise please " \ "press Ctrl-C to stop this script now\nand check the cookie file " \ "at:", launchpad_cookiefile + print "Logging into Launchpad, deleting the above and rerunning this " \ + "script should be enough to generate the cookie." raw_input_exit_on_ctrlc() # Abort if necessary. return True # Sponsorship required. @@ -87,7 +91,15 @@ def checkExistingReports(package): If found ask for confirmation on filing a request. """ - import launchpadbugs.connector as Connector + try: + import launchpadbugs.connector as Connector + except: + print >> sys.stderr, "Unable to import launchpadbugs. Is " \ + "python-launchpad-bugs installed?" + print >> sys.stderr, "Skipping existing report check, you should "\ + "manually check at:" + print "- https://bugs.launchpad.net/ubuntu/+source/%s" % package + return # Connect to the bug list. bugList = Connector.ConnectBugList() @@ -211,23 +223,6 @@ def raw_input_exit_on_ctrlc(*args, **kwargs): print 'Abort requested. No sync request filed.' sys.exit(1) -def usage(): - print '''Usage: requestsync [-d distro|-h|-n|-s|-k |--lp] [basever] - -In some cases, the base version (fork point from Debian) cannot be determined -automatically, and you'll get a complete Debian changelog. Specify the correct -base version of the package in Ubuntu. - -Options: - -d distro Override Debian distribution to sync from [unstable]. - -h Print this help. - -n New source package (doesn't exist yet in Ubuntu). - -s Specify that you require sponsorship. - -k Sign email with (only used when submitting per email). - --lp Use python-launchpad-bugs instead of email for bug submitting. -''' - sys.exit(1) - def get_email_address(): '''Get the DEBEMAIL environment variable or give an error.''' myemailaddr = os.getenv('DEBEMAIL') @@ -446,52 +441,73 @@ def edit_report(subject, body, changes_required=False): # if __name__ == '__main__': - newsource = False - sponsorship = False - keyid = None - use_lp_bugs = False - need_interaction = False - distro = 'unstable' + # Our usage options. + usage = "Usage: %prog [-d distro] [-k keyid] [-n] [--lp] [-s]