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