New feature: Accept a list of bug numbers.

This commit is contained in:
Benjamin Drung 2010-02-13 01:57:49 +01:00
parent 3a922e8752
commit 4a143146c3

125
ack-sync
View File

@ -26,7 +26,6 @@ import glob
import fnmatch
from ubuntutools.lp.libsupport import get_launchpad
from ubuntutools.requestsync.common import raw_input_exit_on_ctrlc
COMMAND_LINE_SYNTAX_ERROR = 1
VERSION_DETECTION_FAILED = 2
@ -109,25 +108,7 @@ def test_install(dsc_file):
except subprocess.CalledProcessError:
print >> sys.stderr, "E: %s failed to install. Please check log" % (changes_file)
def main(bug_number, package, version, section, update, verbose=False, silent=False):
launchpad = get_launchpad("ubuntu-dev-tools")
bug = launchpad.bugs[bug_number]
task = list(bug.bug_tasks)[0]
if package is None:
package = task.bug_target_name.split(" ")[0]
if package == "ubuntu":
# no source package was defined. Guessing that the second word in
# the title is the package name
package = bug.title.split(" ")[1]
if version is None:
version = get_version(bug.title)
print "package:", package
print "version:", version
dsc_file = get_source(package, version, section)
def main(bug_numbers, package, version, section, update, verbose=False, silent=False):
# update pbuilder
if update:
if sbuild:
@ -135,38 +116,60 @@ def main(bug_number, package, version, section, update, verbose=False, silent=Fa
else:
cmd = ["sudo", "env", "DIST=lucid", "pbuilder", "update"]
subprocess.call(LogCall(cmd))
build_source(dsc_file)
if piuparts:
test_install(dsc_file)
print bug.title
print task.assignee
print task.status
raw_input_exit_on_ctrlc('Press [Enter] to continue or [Ctrl-C] to abort. ')
launchpad = get_launchpad("ubuntu-dev-tools")
people = launchpad.people
uus = people['ubuntu-universe-sponsors']
bug.unsubscribe(person=uus)
print "uus unsubscribed"
task.transitionToAssignee(assignee=None)
print "unassigned me"
task.transitionToStatus (status="Triaged")
print "status set to Triaged"
if task.importance == "Undecided":
task.transitionToImportance(importance="Wishlist")
print "importance set to Wishlist"
if piuparts:
bug.newMessage(content="package builds and installs, sync request ACK'd")
else:
bug.newMessage(content="package builds, sync request ACK'd")
print "Ack comment added"
aa = people['ubuntu-archive']
bug.subscribe(person=aa)
print "Archive admin subscribed"
bug.subscribe(person=launchpad.me)
print "subscribed me"
for bug_number in bug_numbers:
bug = launchpad.bugs[bug_number]
task = list(bug.bug_tasks)[0]
if package is None:
package = task.bug_target_name.split(" ")[0]
if package == "ubuntu":
# no source package was defined. Guessing that the second word in
# the title is the package name
package = bug.title.split(" ")[1]
if version is None:
version = get_version(bug.title)
print "package:", package
print "version:", version
dsc_file = get_source(package, version, section)
build_source(dsc_file)
if piuparts:
test_install(dsc_file)
print bug.title
print task.assignee
print task.status
try:
raw_input('Press [Enter] to continue or [Ctrl-C] to abort.')
except KeyboardInterrupt:
continue
people = launchpad.people
uus = people['ubuntu-universe-sponsors']
bug.unsubscribe(person=uus)
print "uus unsubscribed"
task.transitionToAssignee(assignee=None)
print "unassigned me"
task.transitionToStatus (status="Triaged")
print "status set to Triaged"
if task.importance == "Undecided":
task.transitionToImportance(importance="Wishlist")
print "importance set to Wishlist"
if piuparts:
bug.newMessage(content="package builds and installs, sync request ACK'd")
else:
bug.newMessage(content="package builds, sync request ACK'd")
print "Ack comment added"
aa = people['ubuntu-archive']
bug.subscribe(person=aa)
print "Archive admin subscribed"
bug.subscribe(person=launchpad.me)
print "subscribed me"
def usage():
print """ack-sync <bug numbers>
@ -228,15 +231,19 @@ if __name__ == '__main__':
else:
assert False, "unhandled option"
if len(args) != 1:
if len(args) == 0:
if not silent:
print >> sys.stderr, "E: You must specify bug number."
print >> sys.stderr, "E: You must specify at least one bug number."
sys.exit(COMMAND_LINE_SYNTAX_ERROR)
try:
bug_number = int(args[0])
except:
if not silent:
print >> sys.stderr, "E: '%s' is not a valid bug number." % args[0]
sys.exit(COMMAND_LINE_SYNTAX_ERROR)
main(bug_number, package, version, section, update, verbose, silent)
bug_numbers = []
for arg in args:
try:
number = int(arg)
except:
if not silent:
print >> sys.stderr, "E: '%s' is not a valid bug number." % arg
sys.exit(COMMAND_LINE_SYNTAX_ERROR)
bug_numbers.append(number)
main(bug_numbers, package, version, section, update, verbose, silent)