1341.1.1
by Steve Langasek
New script to handle closing bug tasks for EOL series (https://wiki.ubuntu.com/EndOfLifeProcess) |
1 |
#!/usr/bin/python3
|
2 |
# -*- coding: utf-8 -*-
|
|
3 |
||
4 |
# Copyright (C) 2020 Canonical Ltd.
|
|
5 |
||
6 |
# This program is free software: you can redistribute it and/or modify
|
|
7 |
# it under the terms of the GNU General Public License as published by
|
|
8 |
# the Free Software Foundation; version 3 of the License.
|
|
9 |
#
|
|
10 |
# This program is distributed in the hope that it will be useful,
|
|
11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
# GNU General Public License for more details.
|
|
14 |
#
|
|
15 |
# You should have received a copy of the GNU General Public License
|
|
16 |
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17 |
||
18 |
"""Close out remaining open bug tasks in Launchpad for an EOL series."""
|
|
19 |
||
20 |
import argparse |
|
21 |
from launchpadlib.launchpad import Launchpad |
|
22 |
import sys |
|
23 |
||
24 |
CONSUMER_KEY = "close-EOL-bugs" |
|
25 |
||
26 |
def close_bugs_for_series(series): |
|
27 |
bugs = series.searchTasks(status=('New', 'Confirmed', 'Incomplete', |
|
28 |
'Triaged', 'In Progress', |
|
1341.1.2
by Steve Langasek
don't bother closing bugs that are marked as duplicates |
29 |
'Fix Committed'), |
30 |
omit_duplicates=True) |
|
1341.1.4
by Steve Langasek
Spell out EOL in the bug comment |
31 |
message = ('%s has reached end of life, so this bug will not be fixed' |
1365.2.1
by Brian Murray
use title and print a better link |
32 |
' for that release' % series.title) |
1341.1.1
by Steve Langasek
New script to handle closing bug tasks for EOL series (https://wiki.ubuntu.com/EndOfLifeProcess) |
33 |
for task in bugs: |
1365.2.1
by Brian Murray
use title and print a better link |
34 |
print(task.web_link) |
1341.1.1
by Steve Langasek
New script to handle closing bug tasks for EOL series (https://wiki.ubuntu.com/EndOfLifeProcess) |
35 |
task.status = "Won't Fix" |
1341.1.3
by Steve Langasek
Include a message on the bug when closing |
36 |
task.bug.newMessage(content=message) |
1341.1.1
by Steve Langasek
New script to handle closing bug tasks for EOL series (https://wiki.ubuntu.com/EndOfLifeProcess) |
37 |
task.lp_save() |
38 |
||
39 |
def is_series_obsolete(series): |
|
40 |
if series.status != 'Obsolete': |
|
41 |
return False |
|
42 |
return True |
|
43 |
||
44 |
if __name__ == '__main__': |
|
45 |
parser = argparse.ArgumentParser( |
|
46 |
usage="%(prog)s [options] series") |
|
47 |
||
48 |
parser.add_argument( |
|
49 |
"-l", "--launchpad", dest="launchpad_instance", default="production") |
|
50 |
parser.add_argument( |
|
51 |
"series", |
|
52 |
help="series to act on") |
|
53 |
||
54 |
args = parser.parse_args() |
|
55 |
||
56 |
launchpad = Launchpad.login_with( |
|
57 |
CONSUMER_KEY, args.launchpad_instance, version="devel") |
|
58 |
distro = launchpad.distributions["ubuntu"] |
|
59 |
series = distro.getSeries(name_or_version=args.series) |
|
60 |
||
61 |
if not is_series_obsolete(series): |
|
62 |
print("Series %s is not obsolete, aborting." % args.series, |
|
63 |
file=sys.stderr) |
|
64 |
sys.exit(1) |
|
65 |
||
66 |
close_bugs_for_series(series) |