~costamagnagianfranco/ubuntu-archive-tools/ubuntu-archive-tools

« back to all changes in this revision

Viewing changes to close-EOL-bugs

  • Committer: Steve Langasek
  • Date: 2020-07-02 20:31:18 UTC
  • mfrom: (1341.1.4 ubuntu-archive-tools)
  • Revision ID: vorlon@debian.org-20200702203118-15mz7n2r06677pq6
MergeĀ lp:~vorlon/ubuntu-archive-tools/close-EOL-bugs

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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',
 
29
                                      'Fix Committed'),
 
30
                              omit_duplicates=True)
 
31
    message = ('%s has reached end of life, so this bug will not be fixed'
 
32
               ' for that release' % series.name)
 
33
    for task in bugs:
 
34
        print(task)
 
35
        task.status = "Won't Fix"
 
36
        task.bug.newMessage(content=message)
 
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)