~launchpad-pqm/launchpad/devel

5821.1.5 by Michael Hudson
a test. which does not work
1
#!/usr/bin/python2.4
5821.1.2 by Michael Hudson
the script, with some wibbling
2
# Copyright 2008 Canonical Ltd.  All rights reserved.
3
6092.1.7 by Michael Hudson
mostly lint
4
"""Process a code import described by the command line arguments.
5
6
By 'processing a code import' we mean importing or updating code from a
7
remote, non-Bazaar, repository.
8
9
This script is usually run by the code-import-worker-db.py script that
10
communicates progress and results to the database.
5821.1.10 by Michael Hudson
comments from the review
11
"""
5821.1.2 by Michael Hudson
the script, with some wibbling
12
13
__metaclass__ = type
14
15
5821.1.9 by Michael Hudson
fix lint
16
# pylint: disable-msg=W0403
5821.1.2 by Michael Hudson
the script, with some wibbling
17
import _pythonpath
18
6015.2.3 by Michael Hudson
move the rest of the worker gubbins over to the non-db style
19
from optparse import OptionParser
20
5821.1.2 by Michael Hudson
the script, with some wibbling
21
from canonical.codehosting.codeimport.worker import (
6015.2.4 by Michael Hudson
docstrings and some renaming
22
    CodeImportSourceDetails, ImportWorker, get_default_bazaar_branch_store,
5821.1.4 by Michael Hudson
simplifications from jml
23
    get_default_foreign_tree_store)
6015.2.3 by Michael Hudson
move the rest of the worker gubbins over to the non-db style
24
from canonical.launchpad import scripts
25
26
27
28
class CodeImportWorker:
29
30
    def __init__(self):
31
        parser = OptionParser()
32
        scripts.logger_options(parser)
33
        options, self.args = parser.parse_args()
34
        self.logger = scripts.logger(options, 'code-import-worker')
35
5821.1.2 by Michael Hudson
the script, with some wibbling
36
    def main(self):
6015.2.4 by Michael Hudson
docstrings and some renaming
37
        source_details = CodeImportSourceDetails.fromArguments(self.args)
5821.1.2 by Michael Hudson
the script, with some wibbling
38
        import_worker = ImportWorker(
6015.2.3 by Michael Hudson
move the rest of the worker gubbins over to the non-db style
39
            source_details, get_default_foreign_tree_store(),
5821.1.4 by Michael Hudson
simplifications from jml
40
            get_default_bazaar_branch_store(), self.logger)
5821.1.2 by Michael Hudson
the script, with some wibbling
41
        import_worker.run()
42
5821.1.3 by Michael Hudson
ok, there were config entries already
43
5821.1.2 by Michael Hudson
the script, with some wibbling
44
if __name__ == '__main__':
6015.2.3 by Michael Hudson
move the rest of the worker gubbins over to the non-db style
45
    script = CodeImportWorker()
46
    script.main()