Add option parsing to massfile, for lpinstance, correct manpage's view on file locations

This commit is contained in:
Stefano Rivera 2010-12-23 12:35:41 +02:00
parent 2de4aecc4f
commit 86b7ff977c
3 changed files with 52 additions and 11 deletions

View File

@ -3,15 +3,25 @@
\fBmassfile\fR \- script for massfiling bugs against Ubuntu packages
.SH SYNOPSIS
\fBmassfile\fR <path to instructions file> <path to list file>
\fBmassfile\fR [\fIoptions\fR]
.SH DESCRIPTION
\fBmassfile\fR is a script for massfiling bugs against Ubuntu packages in Launchpad. It requires an instructions file describing the contents of the bug report and a list file which lists the packages which the bug will be filed against.
Templates for both files can be found in /usr/share/doc/ubuntu-dev-tools/examples.
.SH OPTIONS
.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 EXAMPLES
\fBmassfile.instructions\fR - file designating the contents of the bug report
\fBinstructions\fR - file designating the contents of the bug report
subject: [UNMETDEPS] $pack has unmet dependencies
assignee:
@ -30,13 +40,29 @@ Templates for both files can be found in /usr/share/doc/ubuntu-dev-tools/example
.
Please have a look and make sure it's installable again.
\fBmassfile.list\fR - file designating the packages affected
\fBlist\fR - file designating the packages affected
Each package should be listed on a new line as follows:
z88dk
zope-quotafolder
.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 MASSFILE_LPINSTANCE ", " UBUNTUTOOLS_LPINSTANCE
The default value for \fB--lpinstance\fR.
.SH AUTHORS
\fBmassfile\fR was written by Iain Lane <iain@orangesquash.org.uk>, Daniel Hahler <ubuntu@thequod.de>. and Markus Korn <thekorn@gmx.de>.

View File

@ -23,10 +23,12 @@
#
# ##################################################################
import optparse
import os
import sys
import email
from ubuntutools.config import UDTConfig
from ubuntutools.lp.libsupport import get_launchpad, translate_api_web, translate_web_api
def read_config():
@ -77,9 +79,7 @@ def check_configfiles():
return result
def file_bug(config):
launchpad = get_launchpad("ubuntu-dev-tools")
def file_bug(config, launchpad):
try:
summary = config["subject"].replace("$pack", config["sourcepackage"])
description = config["text"].replace("$pack", config["sourcepackage"])
@ -113,7 +113,7 @@ def file_bug(config):
except:
"Bug for '%s' was not filed." % config["sourcepackage"]
def read_buglist(url):
def read_buglist(url, launchpad):
if not url:
return set()
@ -122,7 +122,6 @@ def read_buglist(url):
print >> sys.stderr, "Options in url are not supported, url: %s" %url
sys.exit(1)
launchpad = get_launchpad("ubuntu-dev-tools")
packages = set()
api_url = translate_web_api(url, launchpad)
@ -138,17 +137,34 @@ def read_buglist(url):
return packages
def main():
p = optparse.OptionParser(description=
'Files bugs against multiple packages in Ubuntu. '
'Reads the bug from "instructions" and files them against '
'packages listed in "list". '
"If these files aren't preset they are created.")
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()
udtconfig = UDTConfig(options.no_conf)
if options.lpinstance is None:
options.lpinstance = udtconfig.get_value('LPINSTANCE')
if not check_configfiles():
sys.exit(1)
launchpad = get_launchpad('ubuntu-dev-tools' server=options.lpinstance)
config = read_config()
pack_list = read_list()
buglist = read_buglist(config["buglist-url"])
buglist = read_buglist(config["buglist-url"], launchpad)
for pack in pack_list:
if pack not in buglist:
config["sourcepackage"] = pack
file_bug(config)
file_bug(config, launchpad)
if __name__ == '__main__':

View File

@ -30,7 +30,6 @@ BLACKLIST = {
'get-build-deps': 'No Help, runs sudo',
'grep-merges': 'No Help',
'lp-project-upload': 'Returns non-zero after help. Leaving u-d-t in LP: #524680',
'massfile': 'No Help. Leaves files in .',
'mk-sbuild': 'Fires up apt-get before showing help',
'pbuilder-dist-simple': 'No Help',
'setup-packaging-environment': 'Throws Error',