ubuntu-dev-tools/lp-list-bugs

64 lines
2.1 KiB
Plaintext
Raw Permalink Normal View History

2010-09-17 12:45:52 +01:00
#! /usr/bin/python
# -*- coding: UTF-8 -*-
"""Briefly list status of Launchpad bugs."""
# Copyright (c) 2010 Canonical Ltd.
#
# lp-set-dup is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3, or (at your option) any
# later version.
#
# lp-set-dup is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with lp-set-dup; see the file COPYING. If not, write to the Free
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301, USA.
#
# Authors:
# Colin Watson <cjwatson@ubuntu.com>
import sys
from optparse import OptionParser
from launchpadlib.launchpad import Launchpad
2010-09-17 12:45:52 +01:00
from launchpadlib.errors import HTTPError
2010-12-27 21:54:31 +01:00
def main():
2010-09-17 12:45:52 +01:00
usage = "Usage: %prog <bug> [...]"
parser = OptionParser(usage)
2010-12-27 21:54:31 +01:00
args = parser.parse_args()[1]
2010-09-17 12:45:52 +01:00
if len(args) < 1:
parser.error("Need at least one bug number")
try:
launchpad = Launchpad.login_with('ubuntu-dev-tools', 'production')
2010-12-27 21:54:31 +01:00
except Exception, error:
print >> sys.stderr, 'Could not connect to Launchpad:', str(error)
2010-09-17 12:45:52 +01:00
sys.exit(2)
for bugnum in args:
try:
2010-12-27 21:54:31 +01:00
bug = launchpad.bugs[bugnum]
2010-09-17 12:45:52 +01:00
print "Bug %s: %s" % (bugnum, bug.title)
for task in bug.bug_tasks:
print " %s: %s" % (task.bug_target_name, task.status)
2010-12-27 21:54:31 +01:00
except HTTPError, error:
if error.response.status == 401:
2010-12-27 14:01:03 +01:00
print >> sys.stderr, \
2010-09-17 12:45:52 +01:00
("E: Don't have enough permissions to access bug %s" %
bugnum)
2010-12-27 21:54:31 +01:00
print >> sys.stderr, error.content
2010-09-17 12:45:52 +01:00
continue
2010-12-27 21:54:31 +01:00
elif error.response.status == 404:
2010-12-27 14:01:03 +01:00
print >> sys.stderr, "E: Bug %s not found" % bugnum
2010-09-17 12:45:52 +01:00
else:
raise
2010-12-27 21:54:31 +01:00
if __name__ == '__main__':
main()