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 |
13970.7.5
by William Grant
bug-export.py too. |
10 |
|
11 |
import transaction |
|
3691.162.3
by James Henstridge
driver script for bug export |
12 |
from zope.component import getUtility |
14612.2.7
by William Grant
scripts |
13 |
|
14 |
from lp.bugs.scripts.bugexport import export_bugtasks |
|
11882.2.2
by Jonathan Lange
Clear up a heck of a lot of imports from canonical.launchpad.interfaces. |
15 |
from lp.registry.interfaces.product import IProductSet |
13970.7.5
by William Grant
bug-export.py too. |
16 |
from lp.services.scripts.base import LaunchpadScript |
17 |
||
18 |
||
19 |
class BugExportScript(LaunchpadScript): |
|
20 |
||
21 |
description = "Export bugs for a Launchpad product as XML" |
|
22 |
||
23 |
def add_my_options(self): |
|
24 |
self.parser.add_option( |
|
25 |
'-o', '--output', metavar='FILE', action='store', |
|
26 |
help='Export bugs to this file', type='string', dest='output') |
|
27 |
self.parser.add_option( |
|
28 |
'-p', '--product', metavar='PRODUCT', action='store', |
|
29 |
help='Which product to export', type='string', dest='product') |
|
30 |
self.parser.add_option( |
|
31 |
'--include-private', action='store_true', |
|
32 |
help='Include private bugs in dump', dest='include_private', |
|
33 |
default=False) |
|
34 |
||
35 |
def main(self): |
|
36 |
if self.options.product is None: |
|
37 |
self.parser.error('No product specified') |
|
38 |
output = sys.stdout |
|
39 |
if self.options.output is not None: |
|
40 |
output = open(self.options.output, 'wb') |
|
41 |
||
42 |
product = getUtility(IProductSet).getByName(self.options.product) |
|
43 |
if product is None: |
|
44 |
self.parser.error( |
|
45 |
'Product %s does not exist' % self.options.product) |
|
46 |
||
47 |
export_bugtasks( |
|
48 |
transaction, product, output, |
|
49 |
include_private=self.options.include_private) |
|
3691.162.3
by James Henstridge
driver script for bug export |
50 |
|
51 |
if __name__ == '__main__': |
|
13970.7.5
by William Grant
bug-export.py too. |
52 |
BugExportScript("bug-export").run() |