~launchpad-pqm/launchpad/devel

3944.1.1 by Francis J. Lacoste
Use system version python2.4 for scripts.
1
#!/usr/bin/python2.4
3691.201.5 by James Henstridge
sourceforge importer driver script
2
# Copyright 2006 Canonical Ltd.  All rights reserved.
3
4
import logging
5
import optparse
3691.201.38 by James Henstridge
fixes from spiv's review
6
import sys
3691.201.5 by James Henstridge
sourceforge importer driver script
7
8
import _pythonpath
9
10
from zope.component import getUtility
11
from canonical.config import config
12
from canonical.lp import initZopeless
13
from canonical.launchpad.interfaces import IProductSet
14
from canonical.launchpad.scripts import (
15
    execute_zcml_for_scripts, logger_options, logger)
16
from canonical.launchpad.ftests import login
17
3691.201.6 by James Henstridge
fixes to get import working with siproxd test data
18
from canonical.launchpad.scripts.sftracker import Tracker, TrackerImporter
3691.201.5 by James Henstridge
sourceforge importer driver script
19
20
def main(argv):
21
    parser = optparse.OptionParser(description="This script imports bugs "
22
                                   "from Sourceforge into Launchpad.")
23
24
    parser.add_option('--product', metavar='PRODUCT', action='store',
25
                      help='The product to associate bugs with',
26
                      type='string', dest='product', default=None)
27
    parser.add_option('--dumpfile', metavar='XML', action='store',
28
                      help='The XML tracker data dump',
29
                      type='string', dest='dumpfile', default=None)
30
    parser.add_option('--dumpdir', metavar='DIR', action='store',
31
                      help='The directory with the dumped tracker data',
32
                      type='string', dest='dumpdir', default=None)
3691.201.6 by James Henstridge
fixes to get import working with siproxd test data
33
    parser.add_option('--verify-users', dest='verify_users',
34
                      help='Should created users have verified emails?',
35
                      action='store_true', default=False)
3691.201.5 by James Henstridge
sourceforge importer driver script
36
3691.201.6 by James Henstridge
fixes to get import working with siproxd test data
37
    logger_options(parser, logging.INFO)
3691.201.5 by James Henstridge
sourceforge importer driver script
38
39
    options, args = parser.parse_args(argv[1:])
40
    logger(options, 'canonical.launchpad.scripts.sftracker')
41
42
    # don't send email
43
    config.zopeless.send_email = False
44
45
    ztm = initZopeless()
46
    execute_zcml_for_scripts()
3691.201.30 by James Henstridge
change bugzilla-importer to bug-importer in tests
47
    login('bug-importer@launchpad.net')
3691.201.5 by James Henstridge
sourceforge importer driver script
48
49
    product = getUtility(IProductSet).getByName(options.product)
50
    tracker = Tracker(options.dumpfile, options.dumpdir)
3691.201.6 by James Henstridge
fixes to get import working with siproxd test data
51
    importer = TrackerImporter(product, options.verify_users)
3691.201.5 by James Henstridge
sourceforge importer driver script
52
53
    importer.importTracker(ztm, tracker)
54
55
if __name__ == '__main__':
56
    sys.exit(main(sys.argv))