Config file support for grab-attachments (almost doubling its size) :P

This commit is contained in:
Stefano Rivera 2010-12-21 22:42:29 +02:00
parent eedb60b296
commit 86facf23c2
2 changed files with 42 additions and 8 deletions

View File

@ -2,7 +2,7 @@
.SH NAME .SH NAME
grab\-attachments \- downloads attachments from a Launchpad bug grab\-attachments \- downloads attachments from a Launchpad bug
.SH SYNOPSIS .SH SYNOPSIS
.B grab\-attachments\fR <\fIbug-number\fR> .B grab\-attachments\fR [\fIoptions\fR] \fIbug-number\fR...
.br .br
.B grab\-attachments \-h .B grab\-attachments \-h
.SH DESCRIPTION .SH DESCRIPTION
@ -12,13 +12,36 @@ Launchpad bug report into the current directory.
.SH OPTIONS .SH OPTIONS
Listed below are the command line options for grab\-attachments: Listed below are the command line options for grab\-attachments:
.TP .TP
.B \-h .I bug-number
Display a help message and exit.
.TP
.B <bug-number>
Specifies the Launchpad bug number that the script should download Specifies the Launchpad bug number that the script should download
attachments from. attachments from.
.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 GRAB_ATTACHMENTS_LPINSTANCE ", " UBUNTUTOOLS_LPINSTANCE
The default value for \fB--lpinstance\fR.
.SH SEE ALSO
.BR ubuntu\-dev\-tools (5)
.SH AUTHOR .SH AUTHOR
\fBgrab\-attachments\fR was written by Daniel Holbach and this manual page \fBgrab\-attachments\fR was written by Daniel Holbach and this manual page
was written by Jonathan Patrick Davies. was written by Jonathan Patrick Davies.

View File

@ -1,7 +1,8 @@
#!/usr/bin/python #!/usr/bin/python
# #
# Copyright (C) 2007, Canonical Ltd. # Copyright (C) 2007, Canonical Ltd.
# Written by Daniel Holbach # Written by Daniel Holbach,
# Stefano Rivera
# #
# ################################################################## # ##################################################################
# #
@ -22,18 +23,28 @@ from optparse import OptionParser
import os import os
import sys import sys
from ubuntutools.config import UDTConfig
from ubuntutools.lp.libsupport import get_launchpad from ubuntutools.lp.libsupport import get_launchpad
USAGE = "grab-attachments <bug numbers>" USAGE = "grab-attachments <bug numbers>"
def main(): def main():
p = OptionParser('Usage: %prog [options] <bug numbers>') p = OptionParser('Usage: %prog [options] <bug numbers>')
p.add_option('-l', '--lpinstance', metavar='INSTANCE',
dest='lpinstance', default=None,
help='Launchpad instance to connect to (default: production)')
p.add_option('--no-conf',
dest='no_conf', default=False, action='store_true',
help="Don't read config files or environment variables")
opts, args = p.parse_args() opts, args = p.parse_args()
if len(args) < 1: if len(args) < 1:
p.error('No bug numbers provided') p.error('No bug numbers provided')
config = UDTConfig(opts.no_conf)
if opts.lpinstance is None:
opts.lpinstance = config.get_value('LPINSTANCE')
try: try:
launchpad = get_launchpad("ubuntu-dev-tools") launchpad = get_launchpad("ubuntu-dev-tools", server=opts.lpinstance)
for arg in args: for arg in args:
try: try: