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