Debian Codegraph @

bin/lp-list-bugs

raw
1 #! /usr/bin/python3
2 # -*- coding: UTF-8 -*-
3 """Briefly list status of Launchpad bugs."""
4
5 # Copyright (c) 2010 Canonical Ltd.
6 #
7 # lp-set-dup is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by the
9 # Free Software Foundation; either version 3, or (at your option) any
10 # later version.
11 #
12 # lp-set-dup is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with lp-set-dup; see the file COPYING. If not, write to the Free
19 # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 # 02110-1301, USA.
21 #
22 # Authors:
23 # Colin Watson <[email protected]>
24
25 import sys
26 from optparse import OptionParser
27
28 from lptools import config
29
30 from launchpadlib.errors import HTTPError
31
32
33 def main():
34 usage = "Usage: %prog <bug> [...]"
35 parser = OptionParser(usage)
36 args = parser.parse_args()[1]
37 if len(args) < 1:
38 parser.error("Need at least one bug number")
39
40 launchpad = config.get_launchpad("list-bugs")
41
42 for bugnum in args:
43 try:
44 bug = launchpad.bugs[bugnum]
45 print("Bug %s: %s" % (bugnum, bug.title))
46 for task in bug.bug_tasks:
47 print(" %s: %s" % (task.bug_target_name, task.status))
48 except HTTPError as error:
49 if error.response.status == 401:
50 print(("E: Don't have enough permissions to access bug %s" %
51 bugnum), file=sys.stderr)
52 print(error.content, file=sys.stderr)
53 continue
54 elif error.response.status == 404:
55 print("E: Bug %s not found" % bugnum, file=sys.stderr)
56 else:
57 raise
58
59 if __name__ == '__main__':
60 main()