3944.1.1
by Francis J. Lacoste
Use system version python2.4 for scripts. |
1 |
#!/usr/bin/python2.4
|
3691.162.3
by James Henstridge
driver script for bug export |
2 |
# Copyright 2006 Canonical Ltd. All rights reserved.
|
3 |
||
4 |
import sys |
|
5 |
import optparse |
|
6 |
||
7 |
import _pythonpath |
|
8 |
||
9 |
from zope.component import getUtility |
|
10 |
from canonical.lp import initZopeless |
|
11 |
from canonical.launchpad.interfaces import IProductSet |
|
12 |
from canonical.launchpad.scripts import execute_zcml_for_scripts |
|
13 |
||
14 |
from canonical.launchpad.scripts.bugexport import export_bugtasks |
|
15 |
||
16 |
def main(argv): |
|
17 |
parser = optparse.OptionParser( |
|
18 |
description="Export bugs for a Launchpad product as XML") |
|
19 |
parser.add_option('-o', '--output', metavar='FILE', action='store', |
|
20 |
help='Export bugs to this file', |
|
21 |
type='string', dest='output', default=None) |
|
22 |
parser.add_option('-p', '--product', metavar='PRODUCT', action='store', |
|
23 |
help='Which product to export', |
|
24 |
type='string', dest='product', default=None) |
|
3691.162.6
by James Henstridge
add support for including private bugs in the export |
25 |
parser.add_option('--include-private', action='store_true', |
26 |
help='Include private bugs in dump', |
|
27 |
dest='include_private', default=False) |
|
3691.162.3
by James Henstridge
driver script for bug export |
28 |
|
29 |
options, args = parser.parse_args(argv[1:]) |
|
30 |
||
31 |
if options.product is None: |
|
32 |
parser.error('No product specified') |
|
33 |
output = sys.stdout |
|
34 |
if options.output is not None: |
|
35 |
output = open(options.output, 'wb') |
|
36 |
||
37 |
execute_zcml_for_scripts() |
|
38 |
ztm = initZopeless() |
|
39 |
||
40 |
product = getUtility(IProductSet).getByName(options.product) |
|
41 |
if product is None: |
|
42 |
parser.error('Product %s does not exist' % options.product) |
|
43 |
||
3691.440.6
by James Henstridge
fix a small typo in the bug-export.py script |
44 |
export_bugtasks(ztm, product, output, |
45 |
include_private=options.include_private) |
|
3691.162.3
by James Henstridge
driver script for bug export |
46 |
|
47 |
if __name__ == '__main__': |
|
48 |
sys.exit(main(sys.argv)) |