mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-12 23:51:08 +00:00
72 lines
2.4 KiB
Plaintext
72 lines
2.4 KiB
Plaintext
|
#!/usr/bin/python
|
||
|
"""Add 'bitesize' tag to bugs and add a comment."""
|
||
|
|
||
|
# Copyright (c) 2011 Canonical Ltd.
|
||
|
#
|
||
|
# bitesize 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.
|
||
|
#
|
||
|
# bitesize 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:
|
||
|
# Daniel Holbach <daniel.holbach@canonical.com>
|
||
|
|
||
|
import sys
|
||
|
from optparse import OptionParser
|
||
|
|
||
|
from launchpadlib.launchpad import Launchpad
|
||
|
from launchpadlib.errors import HTTPError
|
||
|
|
||
|
def die(message):
|
||
|
print >> sys.stderr, "Fatal: " + message
|
||
|
sys.exit(1)
|
||
|
|
||
|
def main():
|
||
|
usage = "Usage: %prog <bug number>"
|
||
|
opt_parser = OptionParser(usage)
|
||
|
(options, args) = opt_parser.parse_args()
|
||
|
|
||
|
if len(args) < 1:
|
||
|
opt_parser.error("Need at least one bug number.")
|
||
|
|
||
|
launchpad = None
|
||
|
try:
|
||
|
launchpad = Launchpad.login_with("ubuntu-dev-tools", "production")
|
||
|
except ImportError:
|
||
|
suggestion = "check whether python-launchpadlib is installed"
|
||
|
if launchpad is None:
|
||
|
die("Couldn't setup Launchpad for the ubuntu-dev-tools consumer; %s" % \
|
||
|
(suggestion, ))
|
||
|
|
||
|
# check that the new main bug isn't a duplicate
|
||
|
try:
|
||
|
bug = launchpad.bugs[args[0]]
|
||
|
except HTTPError, error:
|
||
|
if error.response.status == 401:
|
||
|
print >> sys.stderr, ("E: Don't have enough permissions to access "
|
||
|
"bug %s") % (args[0])
|
||
|
die(error.content)
|
||
|
else:
|
||
|
raise
|
||
|
if 'bitesize' not in bug.tags:
|
||
|
bug.tags += ['bitesize']
|
||
|
content = """I'm marking this bug as 'bitesize' as it looks like an issue that
|
||
|
is easy to fix and suitable for newcomers in Ubuntu development. If you need
|
||
|
any help with fixing it, talk to me (https://launchpad.net/~%s) about it.""" % \
|
||
|
(launchpad.me.name)
|
||
|
bug.newMessage(content=content, subject="bitesize bug")
|
||
|
bug.lp_save()
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
main()
|