From bd08a0c423adc95a4487fac7f17bb33075415152 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Tue, 21 Dec 2010 23:41:55 +0200 Subject: [PATCH 1/2] Config file for import-bug-from-debian --- doc/import-bug-from-debian.1 | 30 ++++++++++++++++++++++++----- import-bug-from-debian | 37 ++++++++++++++++++++++-------------- 2 files changed, 48 insertions(+), 19 deletions(-) diff --git a/doc/import-bug-from-debian.1 b/doc/import-bug-from-debian.1 index e12ecd7..da8b723 100644 --- a/doc/import-bug-from-debian.1 +++ b/doc/import-bug-from-debian.1 @@ -18,15 +18,35 @@ Each \fIbug\fR may be provided either as a bug number or URL. .SH OPTIONS .TP +.BR \-b ", " \-\-browserless +Don't open the bug in a browser at the end. +.TP .BR \-h ", " \-\-help Display a help message and exit. .TP -.BR \-n ", " \-\-dry\-run -Use the LP staging server so that changes are not permanent. +.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 -.BR \-b ", " \-\-browserless -Don't open the bug in a browser at the end. - +.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 \fBimport\-bug\-from\-debian\fR was written by James Westby , diff --git a/import-bug-from-debian b/import-bug-from-debian index e147088..185d7b2 100755 --- a/import-bug-from-debian +++ b/import-bug-from-debian @@ -1,7 +1,8 @@ #!/usr/bin/python # -*- coding: UTF-8 -*- -# Copyright © 2009 James Westby +# Copyright © 2009 James Westby , +# 2010 Stefano Rivera # # ################################################################## # @@ -21,12 +22,15 @@ # # ################################################################## -from optparse import OptionParser +from optparse import OptionParser, SUPPRESS_HELP import re -import SOAPpy import sys import subprocess -from ubuntutools.lp.libsupport import (get_launchpad, translate_api_web) + +import SOAPpy + +from ubuntutools.config import UDTConfig +from ubuntutools.lp.libsupport import get_launchpad, translate_api_web bug_re = re.compile(r"bug=(\d+)") @@ -39,21 +43,26 @@ debbugs = SOAPpy.SOAPProxy(url, namespace) #debbugs.config.dumpSOAPIn = 1 parser = OptionParser(usage="%prog [option] bug ...") -parser.add_option("-n", "--dry-run", - help="Use the staging server so that changes are not permanent", - dest="dry_run", action="store_true") parser.add_option("-b", "--browserless", - help="Don't open the bug in the browser at the end", - dest="browserless", action="store_true") + help="Don't open the bug in the browser at the end", + dest="browserless", action="store_true") +parser.add_option("-l", "--lpinstance", metavar="INSTANCE", + help="Launchpad instance to connect to (default: production)", + dest="lpinstance", default=None) +parser.add_option("-n", "--dry-run", + help=SUPPRESS_HELP, + dest="lpinstance", action="store_const", const="staging") +parser.add_option("--no-conf", dest="no_conf", default=False, + help="Don't read config files or environment variables.", + action="store_true") (options, args) = parser.parse_args() -if options.dry_run: - lp_server = 'staging' -else: - lp_server = 'production' +config = UDTConfig(options.no_conf) +if options.lpinstance is None: + options.lpinstance = config.get_value("LPINSTANCE") try: - lp = get_launchpad("ubuntu-dev-tools", lp_server) + lp = get_launchpad("ubuntu-dev-tools", options.lpinstance) except IOError, msg: print msg print "No credentials, can't continue" From e5ac5620d7312d5ec9ffd8dfd55c4cdff8c7509b Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Wed, 22 Dec 2010 22:56:39 +0200 Subject: [PATCH 2/2] Correct variable name --- doc/import-bug-from-debian.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/import-bug-from-debian.1 b/doc/import-bug-from-debian.1 index da8b723..aede43a 100644 --- a/doc/import-bug-from-debian.1 +++ b/doc/import-bug-from-debian.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 IMPORT_BUG_FROM_DEBIAN_LPINSTANCE ", " UBUNTUTOOLS_LPINSTANCE The default value for \fB--lpinstance\fR. .SH SEE ALSO .BR ubuntu\-dev\-tools (5)