12
13
from zope.component import getUtility
13
from canonical.lp import initZopeless
14
14
from lp.registry.interfaces.product import IProductSet
15
from canonical.launchpad.scripts import execute_zcml_for_scripts
17
16
from lp.bugs.scripts.bugexport import export_bugtasks
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)
28
parser.add_option('--include-private', action='store_true',
29
help='Include private bugs in dump',
30
dest='include_private', default=False)
32
options, args = parser.parse_args(argv[1:])
34
if options.product is None:
35
parser.error('No product specified')
37
if options.output is not None:
38
output = open(options.output, 'wb')
40
execute_zcml_for_scripts()
43
product = getUtility(IProductSet).getByName(options.product)
45
parser.error('Product %s does not exist' % options.product)
47
export_bugtasks(ztm, product, output,
48
include_private=options.include_private)
17
from lp.services.scripts.base import LaunchpadScript
20
class BugExportScript(LaunchpadScript):
22
description = "Export bugs for a Launchpad product as XML"
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',
37
if self.options.product is None:
38
self.parser.error('No product specified')
40
if self.options.output is not None:
41
output = open(self.options.output, 'wb')
43
product = getUtility(IProductSet).getByName(self.options.product)
46
'Product %s does not exist' % self.options.product)
49
transaction, product, output,
50
include_private=self.options.include_private)
50
52
if __name__ == '__main__':
51
sys.exit(main(sys.argv))
53
BugExportScript("bug-export").run()