From dc6b404bc98f291f67f3215bdc3a6d285dc6a80d Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 22 Dec 2010 22:22:05 +0200 Subject: [PATCH 1/3] lp-set-dup: Config file support --- doc/lp-set-dup.1 | 29 ++++++++++++++++++++++++++++- lp-set-dup | 25 ++++++++++++++++++------- 2 files changed, 46 insertions(+), 8 deletions(-) diff --git a/doc/lp-set-dup.1 b/doc/lp-set-dup.1 index 39a7c2b..03d3217 100644 --- a/doc/lp-set-dup.1 +++ b/doc/lp-set-dup.1 @@ -15,11 +15,38 @@ then perform required tasks on Launchpad. .SH OPTIONS Listed below are the command line options for \fBlp\-set\-dup\fR: .TP -.B \-h or \-\-help +.BR \-h ", " \-\-help Display a help message and exit. .TP .B \-f Skip confirmation prompt. +.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 BACKPORTPACKAGE_LPINSTANCE ", " UBUNTUTOOLS_LPINSTANCE +The default value for \fB--lpinstance\fR. + +.SH SEE ALSO +.BR ubuntu\-dev\-tools (5) .SH AUTHORS \fBlp\-set\-dup\fR was written by Loïc Minier , diff --git a/lp-set-dup b/lp-set-dup index 63bb54f..b93d3e4 100755 --- a/lp-set-dup +++ b/lp-set-dup @@ -23,12 +23,13 @@ # Loïc Minier import sys - from optparse import OptionParser -import ubuntutools.lp.libsupport as lp_libsupport from launchpadlib.errors import HTTPError +import ubuntutools.lp.libsupport as lp_libsupport +from ubuntutools.config import UDTConfig + def die(message): print >> sys.stderr, "Fatal: " + message sys.exit(1) @@ -36,19 +37,29 @@ def die(message): if __name__ == '__main__': usage = "Usage: %prog [-f] [...]" optParser = OptionParser(usage) - optParser.add_option("-f", action = "store_true", - dest = "force", default = False, - help = "Skip confirmation prompt") - + optParser.add_option("-f", + help="Skip confirmation prompt", + dest="force", default=False, action="store_true") + optParser.add_option("-l", "--lpinstance", metavar="INSTANCE", + help="Launchpad instance to connect to (default: production)", + dest="lpinstance", default=None) + optParser.add_option("--no-conf", + help="Don't read config files or environment variables.", + dest="no_conf", default=False, action="store_true") (options, args) = optParser.parse_args() if len(args) < 2: optParser.error("Need at least a new main bug and a bug to dup") + config = UDTConfig(options.no_conf) + if options.lpinstance is None: + options.lpinstance = config.get_value("LPINSTANCE") + launchpad = None try: print "Setting up Launchpad" - launchpad = lp_libsupport.get_launchpad("ubuntu-dev-tools") + launchpad = lp_libsupport.get_launchpad("ubuntu-dev-tools", + server=options.lpinstance) print "Launchpad setup complete" except ImportError: suggestion = "check whether python-launchpadlib is installed" From fe2aa64ea96a7a76ad586d0ee6092f439f15b433 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 22 Dec 2010 22:23:53 +0200 Subject: [PATCH 2/3] Improve synopsis markup --- doc/lp-set-dup.1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/lp-set-dup.1 b/doc/lp-set-dup.1 index 03d3217..404b451 100644 --- a/doc/lp-set-dup.1 +++ b/doc/lp-set-dup.1 @@ -3,7 +3,8 @@ lp\-set\-dup \- mark one or more bugs as duplicate of another bug .SH SYNOPSIS -.B lp\-set\-dup [\-f]
[ ...] +.B lp\-set\-dup \fR[\fB\-f\fR] <\fImain bug\fR> <\fIduplicate bug\fR> +[<\fIduplicate bug\fR> ...] .br .B lp\-set\-dup \-\-help From cce5ceb0eca7ab62540581c8772afd5ccfc32754 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 22 Dec 2010 22:57:02 +0200 Subject: [PATCH 3/3] Correct variable name --- doc/lp-set-dup.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/lp-set-dup.1 b/doc/lp-set-dup.1 index 404b451..d694d5d 100644 --- a/doc/lp-set-dup.1 +++ b/doc/lp-set-dup.1 @@ -43,7 +43,7 @@ configuration files. In each case, the script\-specific variable takes precedence over the package\-wide variable. .TP -.BR BACKPORTPACKAGE_LPINSTANCE ", " UBUNTUTOOLS_LPINSTANCE +.BR LP_SET_DUP_LPINSTANCE ", " UBUNTUTOOLS_LPINSTANCE The default value for \fB--lpinstance\fR. .SH SEE ALSO