Added process_bugs.py
This commit is contained in:
parent
c7be5ad71a
commit
a7d3569572
22
README.rst
22
README.rst
|
@ -8,6 +8,28 @@ You'll need the following Python modules installed:
|
|||
- launchpadlib
|
||||
|
||||
|
||||
process_bugs.py
|
||||
-----------------
|
||||
|
||||
This script fetches bugs for a project (by default all "FixCommitted" bugs)
|
||||
and sets a milestone target for them (--settarget) and/or sets their status
|
||||
to "Fix Released" (--fixrelease).
|
||||
|
||||
It ignores bugs that have already a milestone set, if that milestone does
|
||||
not match the one in --settarget.
|
||||
|
||||
Examples:
|
||||
|
||||
./process_bugs.py nova --settarget=grizzly-3 --fixrelease
|
||||
|
||||
Sets the target for all Nova FixCommitted bugs to grizzly-3
|
||||
and mark them 'Fix Released'.
|
||||
|
||||
./process_bugs.py glance --settarget=grizzly-2 --status='Fix Released' --test
|
||||
|
||||
Test setting the target for all untargeted Glance FixReleased bugs to
|
||||
grizzly-2 on Launchpad Staging servers.
|
||||
|
||||
upload_release.py
|
||||
-----------------
|
||||
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
#!/usr/bin/python
|
||||
#
|
||||
# Script to apply bulk changes to Launchpad bugs
|
||||
#
|
||||
# Copyright 2011-2013 Thierry Carrez <thierry@openstack.org>
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from argparse import ArgumentParser
|
||||
from launchpadlib.launchpad import Launchpad
|
||||
|
||||
# Parameters
|
||||
parser = ArgumentParser(description="Change bugs status in bulk")
|
||||
parser.add_argument('projectname', help='The project to act on')
|
||||
parser.add_argument('--status', default='Fix Committed',
|
||||
help='Which bug status to bulk-change')
|
||||
parser.add_argument("--test", action='store_const', const='staging',
|
||||
default='production', help='Use LP staging server to test')
|
||||
parser.add_argument('--settarget',
|
||||
help='ACTION: set the milestone to specified target')
|
||||
parser.add_argument('--fixrelease', action='store_true',
|
||||
help='ACTION: mark bugs fix released')
|
||||
parser.add_argument('exceptions', type=int, nargs='*', help='Bugs to ignore')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.settarget:
|
||||
if args.test:
|
||||
site = "https://api.staging.launchpad.net/1.0"
|
||||
else:
|
||||
site = "https://api.launchpad.net/1.0"
|
||||
milestonelink = "%s/%s/+milestone/%s" \
|
||||
% (site, args.projectname, args.settarget)
|
||||
|
||||
# Connect to Launchpad
|
||||
print "Connecting to Launchpad..."
|
||||
launchpad = Launchpad.login_with('openstack-releasing', args.test)
|
||||
|
||||
# Retrieve bugs
|
||||
print "Retrieving project..."
|
||||
proj = launchpad.projects[args.projectname]
|
||||
numtasks = 1
|
||||
|
||||
while numtasks > 0:
|
||||
bugtasks = proj.searchTasks(status=args.status)
|
||||
numtasks = int(bugtasks._wadl_resource.representation['total_size'])
|
||||
|
||||
# Process bugs
|
||||
for b in bugtasks:
|
||||
bug = b.bug
|
||||
# Skip already-milestoned bugs witghh a different milestone
|
||||
if args.settarget and b.milestone:
|
||||
if b.milestone.name != args.settarget:
|
||||
continue
|
||||
print bug.id,
|
||||
if bug.id in args.exceptions:
|
||||
print " - excepted"
|
||||
continue
|
||||
if args.settarget:
|
||||
b.milestone = milestonelink
|
||||
print " - milestoned",
|
||||
if args.fixrelease:
|
||||
print " - fixreleased",
|
||||
b.status = 'Fix Released'
|
||||
b.lp_save()
|
||||
print
|
Loading…
Reference in New Issue