10637.3.1
by Guilherme Salgado
Use the default python version instead of a hard-coded version |
1 |
#!/usr/bin/python -S
|
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).
|
|
8847.1.5
by Celso Providelo
fixing lint issue. |
5 |
# pylint: disable-msg=W0403
|
3691.162.3
by James Henstridge
driver script for bug export |
6 |
|
9641.1.7
by Gary Poster
fix scripts to work |
7 |
import _pythonpath |
8 |
||
3691.162.3
by James Henstridge
driver script for bug export |
9 |
import sys |
10 |
import optparse |
|
11 |
||
12 |
from zope.component import getUtility |
|
13 |
from canonical.lp import initZopeless |
|
14 |
from canonical.launchpad.interfaces import IProductSet |
|
15 |
from canonical.launchpad.scripts import execute_zcml_for_scripts |
|
16 |
||
8847.1.1
by Celso Providelo
Integrating the tree script checker into the test suite. |
17 |
from lp.bugs.scripts.bugexport import export_bugtasks |
3691.162.3
by James Henstridge
driver script for bug export |
18 |
|
19 |
def main(argv): |
|
20 |
parser = optparse.OptionParser( |
|
21 |
description="Export bugs for a Launchpad product as XML") |
|
22 |
parser.add_option('-o', '--output', metavar='FILE', action='store', |
|
23 |
help='Export bugs to this file', |
|
24 |
type='string', dest='output', default=None) |
|
25 |
parser.add_option('-p', '--product', metavar='PRODUCT', action='store', |
|
26 |
help='Which product to export', |
|
27 |
type='string', dest='product', default=None) |
|
3691.162.6
by James Henstridge
add support for including private bugs in the export |
28 |
parser.add_option('--include-private', action='store_true', |
29 |
help='Include private bugs in dump', |
|
30 |
dest='include_private', default=False) |
|
3691.162.3
by James Henstridge
driver script for bug export |
31 |
|
32 |
options, args = parser.parse_args(argv[1:]) |
|
33 |
||
34 |
if options.product is None: |
|
35 |
parser.error('No product specified') |
|
36 |
output = sys.stdout |
|
37 |
if options.output is not None: |
|
38 |
output = open(options.output, 'wb') |
|
8847.1.1
by Celso Providelo
Integrating the tree script checker into the test suite. |
39 |
|
3691.162.3
by James Henstridge
driver script for bug export |
40 |
execute_zcml_for_scripts() |
41 |
ztm = initZopeless() |
|
42 |
||
43 |
product = getUtility(IProductSet).getByName(options.product) |
|
44 |
if product is None: |
|
45 |
parser.error('Product %s does not exist' % options.product) |
|
46 |
||
3691.440.6
by James Henstridge
fix a small typo in the bug-export.py script |
47 |
export_bugtasks(ztm, product, output, |
48 |
include_private=options.include_private) |
|
3691.162.3
by James Henstridge
driver script for bug export |
49 |
|
50 |
if __name__ == '__main__': |
|
51 |
sys.exit(main(sys.argv)) |