From 3b5d8a0edac7a1d626621ac54562af7d4068ce9f Mon Sep 17 00:00:00 2001 From: Daniel Holbach Date: Fri, 7 Sep 2007 11:47:06 +0200 Subject: [PATCH] revuput: - arguments checking in separate function - -n argument to file a new bug - whitespace changes --- revuput | 66 ++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 49 insertions(+), 17 deletions(-) diff --git a/revuput b/revuput index 7a1c557..645ad4c 100755 --- a/revuput +++ b/revuput @@ -6,7 +6,7 @@ # # # Notes: -# - needs dput, python-launchpad-bugs (>= 0.2.4) +# - needs dput, python-launchpad-bugs (>= 0.2.9) # - needs http://launchpad.net/bugs/137767 to get fixed # @@ -19,7 +19,7 @@ try: import launchpadbugs.connector as Connector except: print >> sys.stderr, \ - "You need python-launchpad-bugs (>= 0.2.4) installed to use revuput." + "You need python-launchpad-bugs (>= 0.2.9) installed to use revuput." sys.exit(1) #try: @@ -29,7 +29,7 @@ except: # sys.exit(1) -USAGE = 'Usage: revuput []' +USAGE = 'Usage: revuput [-n] [] []' def dput_check(): @@ -148,30 +148,62 @@ def deal_with_bugreport(bugnumbers, host, incoming, sourcepackage, version): bug.commit() +def check_arguments(args): + new_bug = False + location = 'default' + debuild_args = list() + + if len(sys.argv) == 1: + return (new_bug, location, debuild_args) + + if sys.argv[1] == "-n": + new_bug = True + if len(sys.argv)>2: + if sys.argv[2].startswith("-"): + debuild_args = sys.argv[2:] + else: + location = sys.argv[2] + if len(sys.argv)>3: + debuild_args = sys.argv[3:] + else: + if sys.argv[1].startswith("-"): + debuild_args.append(sys.argv[1:]) + else: + location = sys.argv[1] + if len(sys.argv)>2: + debuild_args = sys.argv[2:] + + return (new_bug, location, debuild_args) + + +def file_bug(sourcepackage, version): + Bug = Connector.ConnectBug() + Bug.authentication = os.path.expanduser("~/.lpcookie") + + bug = Bug.New(product={"name": sourcepackage, "target": "ubuntu"}, + summary="Please sponsor %s %s" % (sourcepackage, version), + description=\ + "The new package will be uploaded to PPA shortly.") + return bug.bugnumber + def main(): - location = "" - options = [] - - if len(sys.argv)<2: - print >> sys.stderr, USAGE - sys.exit(1) - - location = sys.argv[1] - if len(sys.argv) > 2: - options = sys.argv[2:] - - if not call_debuild(options): + (new_bug, location, debuild_args) = check_arguments(sys.argv) + (sourcepackage, version) = get_name_and_version()[0] + + if new_bug: + bugnumber = file_bug(sourcepackage, version) + os.system("dch -a 'Fixes (LP: #%s)'" % bugnumber) + if not call_debuild(debuild_args): sys.exit(1) - (sourcepackage, version) = get_name_and_version()[0] changesfile = "../%s_%s_source.changes" % (sourcepackage, version) if not os.path.exists(os.path.expanduser(changesfile)): print >> sys.stderr, "%s does not exist." % \ os.path.expanduser(changesfile) sys.exit(1) - host = lookup_dput_host(location) + host = lookup_dput_host(location) (dput_res, incoming) = call_dput(location, changesfile) if not dput_res: sys.exit(1)