From eee6501a18d3c2d26ce516948f9bd1a40d5415a3 Mon Sep 17 00:00:00 2001 From: Daniel Holbach Date: Mon, 9 May 2011 14:48:54 +0200 Subject: [PATCH 1/5] add 'bitesize' script --- bitesize | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ debian/changelog | 7 ++++- debian/copyright | 2 ++ doc/bitesize.1 | 31 +++++++++++++++++++++ 4 files changed, 110 insertions(+), 1 deletion(-) create mode 100755 bitesize create mode 100644 doc/bitesize.1 diff --git a/bitesize b/bitesize new file mode 100755 index 0000000..6f81459 --- /dev/null +++ b/bitesize @@ -0,0 +1,71 @@ +#!/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 + +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 " + 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() diff --git a/debian/changelog b/debian/changelog index bae94ad..46a1d2b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,6 @@ ubuntu-dev-tools (0.124) UNRELEASED; urgency=low + [ Stefano Rivera ] * mk-sbuild: - Disable daemons with a policy-rc.d script (like pbuilder does) - Move package installation after option parsing. @@ -12,7 +13,11 @@ ubuntu-dev-tools (0.124) UNRELEASED; urgency=low code name. - Support Debian experimental. - -- Stefano Rivera Sun, 24 Apr 2011 20:35:51 +0200 + [ Daniel Holbach ] + * bitesize, doc/bitesize.1: add script to tag a bug as bitesize and add a + comment that you are willing to help with fixing the bug. + + -- Daniel Holbach Mon, 09 May 2011 14:33:48 +0200 ubuntu-dev-tools (0.122) unstable; urgency=low diff --git a/debian/copyright b/debian/copyright index c637b65..9602b66 100644 --- a/debian/copyright +++ b/debian/copyright @@ -86,6 +86,7 @@ License: GPL-2+ version 2 can be found in the /usr/share/common-licenses/GPL-2 file. Files: ack-sync + doc/bitesize.1 doc/edit-patch.1 doc/get-branches.1 doc/grab-attachments.1 @@ -96,6 +97,7 @@ Files: ack-sync doc/merge-changelog.1 doc/setup-packaging-environment.1 doc/syncpackage.1 + bitesize edit-patch get-branches grab-attachments diff --git a/doc/bitesize.1 b/doc/bitesize.1 new file mode 100644 index 0000000..a0afbb5 --- /dev/null +++ b/doc/bitesize.1 @@ -0,0 +1,31 @@ +.TH bitesize "1" "May 9 2010" "ubuntu-dev-tools" +.SH NAME +Add \fIbitesize\fI tag to bugs and add a comment. +lp\-set\-dup \- mark one or more bugs as duplicate of another bug + +.SH SYNOPSIS +.B bitesize \fR<\fIbug number\fI>\fR +.br +.B bitesize \-\-help + +.SH DESCRIPTION +\fBbitesize\fR adds a bitesize tag to the bug, if it's not there yet. It +also adds a comment to the bug indicating that you are willing to help with +fixing it. +It checks for permission to operate on a given bug first, +then perform required tasks on Launchpad. + +.SH OPTIONS +Listed below are the command line options for \fBbitesize\fR: +.TP +.BR \-h ", " \-\-help +Display a help message and exit. + +.SH SEE ALSO +.BR ubuntu\-dev\-tools (5) + +.SH AUTHORS +\fBbitesize\fR and this manual page were written by Daniel Holbach +. +.PP +Both are released under the terms of the GNU General Public License, version 3. From b4b217ade58905d313e9df51d8da2e8470507eed Mon Sep 17 00:00:00 2001 From: Daniel Holbach Date: Mon, 9 May 2011 14:52:51 +0200 Subject: [PATCH 2/5] fix leftover 'lp-set-dup --- doc/bitesize.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/bitesize.1 b/doc/bitesize.1 index a0afbb5..67bb37a 100644 --- a/doc/bitesize.1 +++ b/doc/bitesize.1 @@ -1,7 +1,7 @@ .TH bitesize "1" "May 9 2010" "ubuntu-dev-tools" .SH NAME Add \fIbitesize\fI tag to bugs and add a comment. -lp\-set\-dup \- mark one or more bugs as duplicate of another bug +bitesize \- mark one or more bugs as duplicate of another bug .SH SYNOPSIS .B bitesize \fR<\fIbug number\fI>\fR From d94994b1f4188d235edff1770269aef499263d21 Mon Sep 17 00:00:00 2001 From: Daniel Holbach Date: Mon, 9 May 2011 14:57:28 +0200 Subject: [PATCH 3/5] fix leftover 'lp-set-dup --- bitesize | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitesize b/bitesize index 6f81459..67738ac 100755 --- a/bitesize +++ b/bitesize @@ -14,7 +14,7 @@ # 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 +# along with bitesize; see the file COPYING. If not, write to the Free # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA # 02110-1301, USA. # From 7a45eede4aea77dacebcf7bf4090cbdf32e16a83 Mon Sep 17 00:00:00 2001 From: Daniel Holbach Date: Mon, 9 May 2011 15:35:23 +0200 Subject: [PATCH 4/5] add lpinstance/no-conf options, fix manpage --- bitesize | 38 +++++++++++++++++++++++--------------- doc/bitesize.1 | 28 ++++++++++++++++++++++++++-- 2 files changed, 49 insertions(+), 17 deletions(-) diff --git a/bitesize b/bitesize index 67738ac..7ddb100 100755 --- a/bitesize +++ b/bitesize @@ -27,26 +27,34 @@ from optparse import OptionParser from launchpadlib.launchpad import Launchpad from launchpadlib.errors import HTTPError -def die(message): - print >> sys.stderr, "Fatal: " + message +from ubuntutools.logger import Logger +from ubuntutools.config import UDTConfig + +def error_out(msg): + Logger.error(msg) sys.exit(1) def main(): usage = "Usage: %prog " opt_parser = OptionParser(usage) + opt_parser.add_option("-l", "--lpinstance", metavar="INSTANCE", + help="Launchpad instance to connect to " + "(default: production)", + dest="lpinstance", default=None) + opt_parser.add_option("--no-conf", + help="Don't read config files or " + "environment variables.", + dest="no_conf", default=False, action="store_true") (options, args) = opt_parser.parse_args() - + config = UDTConfig(options.no_conf) + if options.lpinstance is None: + options.lpinstance = config.get_value("LPINSTANCE") 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" + launchpad = Launchpad.login_with("ubuntu-dev-tools", options.lpinstance) if launchpad is None: - die("Couldn't setup Launchpad for the ubuntu-dev-tools consumer; %s" % \ - (suggestion, )) + error_out("Couldn't authenticate to Launchpad.") # check that the new main bug isn't a duplicate try: @@ -55,15 +63,15 @@ def main(): if error.response.status == 401: print >> sys.stderr, ("E: Don't have enough permissions to access " "bug %s") % (args[0]) - die(error.content) + error_out(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) + 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() diff --git a/doc/bitesize.1 b/doc/bitesize.1 index 67bb37a..a349d00 100644 --- a/doc/bitesize.1 +++ b/doc/bitesize.1 @@ -1,10 +1,10 @@ .TH bitesize "1" "May 9 2010" "ubuntu-dev-tools" .SH NAME -Add \fIbitesize\fI tag to bugs and add a comment. +Add \fBbitesize\fR tag to bugs and add a comment. bitesize \- mark one or more bugs as duplicate of another bug .SH SYNOPSIS -.B bitesize \fR<\fIbug number\fI>\fR +.B bitesize <\fIbug number\fI> .br .B bitesize \-\-help @@ -20,6 +20,30 @@ Listed below are the command line options for \fBbitesize\fR: .TP .BR \-h ", " \-\-help Display a help message and exit. +.TP +.B \-l \fIINSTANCE\fR, \fB\-\-lpinstance\fR=\fIINSTANCE\fR +Use the specified instance of Launchpad (e.g. "staging"), instead of +the default of "production". +.TP +.B \-\-no\-conf +Do not read any configuration files, or configuration from environment +variables. + +.SH ENVIRONMENT +All of the \fBCONFIGURATION VARIABLES\fR below are also supported as +environment variables. +Variables in the environment take precedence to those in configuration +files. + +.SH CONFIGURATION VARIABLES +The following variables can be set in the environment or in +.BR ubuntu\-dev\-tools (5) +configuration files. +In each case, the script\-specific variable takes precedence over the +package\-wide variable. +.TP +.BR LP_SET_DUP_LPINSTANCE ", " UBUNTUTOOLS_LPINSTANCE +The default value for \fB--lpinstance\fR. .SH SEE ALSO .BR ubuntu\-dev\-tools (5) From aecd1169fd13a2905c6f92067be0e86ae312a521 Mon Sep 17 00:00:00 2001 From: Daniel Holbach Date: Tue, 10 May 2011 12:08:59 +0200 Subject: [PATCH 5/5] fix problems mentioned in review --- bitesize | 3 +-- debian/control | 2 ++ doc/bitesize.1 | 7 +++---- setup.py | 1 + 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/bitesize b/bitesize index 7ddb100..edaa09a 100755 --- a/bitesize +++ b/bitesize @@ -61,8 +61,7 @@ def main(): 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]) + error_out("E: Don't have enough permissions to access bug %s" % args[0]) error_out(error.content) else: raise diff --git a/debian/control b/debian/control index f251572..c12b4e1 100644 --- a/debian/control +++ b/debian/control @@ -66,6 +66,8 @@ Description: useful tools for Ubuntu developers . - 404main - used to check what components a package's deps are in, for doing a main inclusion report for example. + - bitesize - add the 'bitesize' tag to a bug and comment that you are + willing to help fix it. - check-mir - check support status of build/binary dependencies - check-symbols - will compare and give you a diff of the exported symbols of all .so files in a binary package. diff --git a/doc/bitesize.1 b/doc/bitesize.1 index a349d00..68fdca1 100644 --- a/doc/bitesize.1 +++ b/doc/bitesize.1 @@ -1,10 +1,9 @@ .TH bitesize "1" "May 9 2010" "ubuntu-dev-tools" .SH NAME -Add \fBbitesize\fR tag to bugs and add a comment. -bitesize \- mark one or more bugs as duplicate of another bug +bitesize \- Add \fBbitesize\fR tag to bugs and add a comment. .SH SYNOPSIS -.B bitesize <\fIbug number\fI> +.B bitesize \fR<\fIbug number\fR> .br .B bitesize \-\-help @@ -42,7 +41,7 @@ configuration files. In each case, the script\-specific variable takes precedence over the package\-wide variable. .TP -.BR LP_SET_DUP_LPINSTANCE ", " UBUNTUTOOLS_LPINSTANCE +.BR BITESIZE_LPINSTANCE ", " UBUNTUTOOLS_LPINSTANCE The default value for \fB--lpinstance\fR. .SH SEE ALSO diff --git a/setup.py b/setup.py index d2374c8..50ecf3a 100755 --- a/setup.py +++ b/setup.py @@ -15,6 +15,7 @@ if os.path.exists(changelog): scripts = ['404main', 'backportpackage', + 'bitesize', 'check-mir', 'check-symbols', 'dch-repeat',