- arguments checking in separate function
 - -n argument to file a new bug
 - whitespace changes
This commit is contained in:
Daniel Holbach 2007-09-07 11:47:06 +02:00
parent 7445cc9826
commit 3b5d8a0eda

66
revuput
View File

@ -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 <location> [<debuild options>]'
USAGE = 'Usage: revuput [-n] [<location>] [<debuild options>]'
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)