~ubuntu-branches/ubuntu/quantal/lptools/quantal

« back to all changes in this revision

Viewing changes to bin/lp-list-bugs

  • Committer: Package Import Robot
  • Author(s): Jelmer Vernooij, Robert Collins, Jelmer Vernooij
  • Date: 2011-09-01 22:47:11 UTC
  • mfrom: (2.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20110901224711-05u7hwne9anexqq9
Tags: 0.0.1~bzr28-1
[ Robert Collins ]
* Control tweaks.

[ Jelmer Vernooij ]
* New upstream snapshot.
 + Imports a few tools from ubuntu-dev-tools. Breaks/Replaces added.
* Add myself to Uploaders.
* Bump standards version to 3.9.2 (no changes).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/python
 
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 <cjwatson@ubuntu.com>
 
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, error:
 
49
            if error.response.status == 401:
 
50
                print >> sys.stderr, \
 
51
                    ("E: Don't have enough permissions to access bug %s" %
 
52
                     bugnum)
 
53
                print >> sys.stderr, error.content
 
54
                continue
 
55
            elif error.response.status == 404:
 
56
                print >> sys.stderr, "E: Bug %s not found" % bugnum
 
57
            else:
 
58
                raise
 
59
 
 
60
if __name__ == '__main__':
 
61
    main()