~launchpad-pqm/launchpad/devel

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