lp-mark-bugs-released revision ac4dc8c32116eb4089277fd2ef8c3e4700a429a2
9512fe850e98fdd448c638ca63fdd92a8a510255ahl#!/usr/bin/python
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# Copyright (c) 2010 Canonical Ltd.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl#
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# This program is free software; you can redistribute it and/or modify it
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# under the terms of the GNU General Public License version 3 as published
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# by the # Free Software Foundation
9512fe850e98fdd448c638ca63fdd92a8a510255ahl#
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# lp-mark-bugs-released is distributed in the hope that it will be useful, but
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# WITHOUT ANY WARRANTY; without even the implied warranty of
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# General Public License for more details.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl'''Mark bugs that are Fix Committed on a release to be Fix Released'''
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahlimport datetime
9512fe850e98fdd448c638ca63fdd92a8a510255ahlimport os
9512fe850e98fdd448c638ca63fdd92a8a510255ahlimport sys
9512fe850e98fdd448c638ca63fdd92a8a510255ahlimport tempfile
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahlfrom launchpadlib.launchpad import Launchpad
9512fe850e98fdd448c638ca63fdd92a8a510255ahlfrom launchpadlib.errors import HTTPError
73427c57f824c3ec3b396181b163f37d50c5b3b1ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahlopt_dry_run = False
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
73427c57f824c3ec3b396181b163f37d50c5b3b1ahldef mark_released (bug):
73427c57f824c3ec3b396181b163f37d50c5b3b1ahl if bug.status == 'Fix Committed':
9512fe850e98fdd448c638ca63fdd92a8a510255ahl print "Marking bug " + str(bug.bug.id) + " as 'Fix Released'"
9512fe850e98fdd448c638ca63fdd92a8a510255ahl bug.status = "Fix Released"
9512fe850e98fdd448c638ca63fdd92a8a510255ahl if not opt_dry_run:
4fe01614e64281d82c5a22f0050e55f1e0bdbdaeraf bug.lp_save()
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
73427c57f824c3ec3b396181b163f37d50c5b3b1ahldef main():
9512fe850e98fdd448c638ca63fdd92a8a510255ahl if len(sys.argv) != 3:
9512fe850e98fdd448c638ca63fdd92a8a510255ahl print >> sys.stderr, '''Mark bugs 'Fix Committed' on a release as released
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
73427c57f824c3ec3b396181b163f37d50c5b3b1ahl Usage: %s <project name> <version>''' % sys.argv[0]
73427c57f824c3ec3b396181b163f37d50c5b3b1ahl sys.exit(1)
73427c57f824c3ec3b396181b163f37d50c5b3b1ahl
73427c57f824c3ec3b396181b163f37d50c5b3b1ahl (project, version) = sys.argv[1:]
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
73427c57f824c3ec3b396181b163f37d50c5b3b1ahl try:
73427c57f824c3ec3b396181b163f37d50c5b3b1ahl launchpad = Launchpad.login_with('ubuntu-dev-tools', 'production')
9512fe850e98fdd448c638ca63fdd92a8a510255ahl except Exception, error:
73427c57f824c3ec3b396181b163f37d50c5b3b1ahl print >> sys.stderr, 'Could not connect to Launchpad:', str(error)
73427c57f824c3ec3b396181b163f37d50c5b3b1ahl sys.exit(2)
73427c57f824c3ec3b396181b163f37d50c5b3b1ahl
73427c57f824c3ec3b396181b163f37d50c5b3b1ahl try:
9512fe850e98fdd448c638ca63fdd92a8a510255ahl # Look up the project using the Launchpad instance.
73427c57f824c3ec3b396181b163f37d50c5b3b1ahl proj = launchpad.projects[project]
73427c57f824c3ec3b396181b163f37d50c5b3b1ahl # Find the release in the project's releases collection.
release = None
for rel in proj.releases:
if rel.version == version:
release = rel
break
if not release:
print >> sys.stderr, '''Unable to find release: %s''' % version
sys.exit(1)
# Mark any fix committed bugs released
for task in release.milestone.searchTasks(status="Fix Committed"):
if task.milestone is None:
for othertask in task.related_tasks:
if othertask.milestone.name == release.milestone.name:
mark_released(othertask)
else:
mark_released(task)
except HTTPError, error:
print 'An error happened in the upload: %s\n%s' %(
error.content,
error.__dict__)
sys.exit(1)
if __name__ == '__main__':
main()