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