lp-set-dup: Config file support

This commit is contained in:
Stefano Rivera 2010-12-22 22:22:05 +02:00
parent bcf9772206
commit dc6b404bc9
2 changed files with 46 additions and 8 deletions

View File

@ -15,11 +15,38 @@ then perform required tasks on Launchpad.
.SH OPTIONS .SH OPTIONS
Listed below are the command line options for \fBlp\-set\-dup\fR: Listed below are the command line options for \fBlp\-set\-dup\fR:
.TP .TP
.B \-h or \-\-help .BR \-h ", " \-\-help
Display a help message and exit. Display a help message and exit.
.TP .TP
.B \-f .B \-f
Skip confirmation prompt. 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 .SH AUTHORS
\fBlp\-set\-dup\fR was written by Loïc Minier <lool@dooz.org>, \fBlp\-set\-dup\fR was written by Loïc Minier <lool@dooz.org>,

View File

@ -23,12 +23,13 @@
# Loïc Minier <lool@dooz.org> # Loïc Minier <lool@dooz.org>
import sys import sys
from optparse import OptionParser from optparse import OptionParser
import ubuntutools.lp.libsupport as lp_libsupport
from launchpadlib.errors import HTTPError from launchpadlib.errors import HTTPError
import ubuntutools.lp.libsupport as lp_libsupport
from ubuntutools.config import UDTConfig
def die(message): def die(message):
print >> sys.stderr, "Fatal: " + message print >> sys.stderr, "Fatal: " + message
sys.exit(1) sys.exit(1)
@ -36,19 +37,29 @@ def die(message):
if __name__ == '__main__': if __name__ == '__main__':
usage = "Usage: %prog [-f] <new main bug> <bug to dup> [<bug to dup>...]" usage = "Usage: %prog [-f] <new main bug> <bug to dup> [<bug to dup>...]"
optParser = OptionParser(usage) optParser = OptionParser(usage)
optParser.add_option("-f", action = "store_true", optParser.add_option("-f",
dest = "force", default = False, help="Skip confirmation prompt",
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() (options, args) = optParser.parse_args()
if len(args) < 2: if len(args) < 2:
optParser.error("Need at least a new main bug and a bug to dup") 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 launchpad = None
try: try:
print "Setting up Launchpad" 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" print "Launchpad setup complete"
except ImportError: except ImportError:
suggestion = "check whether python-launchpadlib is installed" suggestion = "check whether python-launchpadlib is installed"