10637.3.1
by Guilherme Salgado
Use the default python version instead of a hard-coded version |
1 |
#!/usr/bin/python -S
|
8687.15.7
by Karl Fogel
Add the copyright header block to more 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).
|
|
5849.2.4
by Michael Hudson
stuff |
5 |
|
5849.2.16
by Michael Hudson
one more |
6 |
"""Look for and dispatch code import jobs as needed."""
|
5849.2.4
by Michael Hudson
stuff |
7 |
|
5849.2.17
by Michael Hudson
the usual |
8 |
# pylint: disable-msg=W0403
|
5849.2.4
by Michael Hudson
stuff |
9 |
import _pythonpath |
10 |
||
5849.2.18
by michael.hudson at canonical
review comments |
11 |
from xmlrpclib import ServerProxy |
12 |
||
8426.6.1
by Michael Hudson
bzr ls --versioned --recursive --kind=file | xargs sed -i -e 's,from canonical.codehosting,from lp.codehosting,' |
13 |
from lp.codehosting.codeimport.dispatcher import CodeImportDispatcher |
5849.2.4
by Michael Hudson
stuff |
14 |
from canonical.config import config |
8356.1.1
by Leonard Richardson
Partial move. |
15 |
from lp.services.scripts.base import LaunchpadScript |
5849.2.4
by Michael Hudson
stuff |
16 |
from canonical.launchpad.webapp.errorlog import globalErrorUtility |
17 |
||
18 |
||
6224.1.1
by Michael Hudson
Move database code from the dispatcher to ICodeImportJobSet.getJobForMachine. |
19 |
class CodeImportDispatcherScript(LaunchpadScript): |
20 |
||
10330.2.4
by Michael Hudson
ok, this actually works |
21 |
def add_my_options(self): |
22 |
self.parser.add_option( |
|
23 |
"--max-jobs", dest="max_jobs", type=int, |
|
24 |
default=config.codeimportdispatcher.max_jobs_per_machine, |
|
25 |
help="The maximum number of jobs to run on this machine.") |
|
26 |
||
12415.1.5
by William Grant
Purge implicit_begin/implicitBegin; ignored since Storm. |
27 |
def run(self, use_web_security=False, isolation=None): |
6224.1.1
by Michael Hudson
Move database code from the dispatcher to ICodeImportJobSet.getJobForMachine. |
28 |
"""See `LaunchpadScript.run`.
|
29 |
||
30 |
We override to avoid all of the setting up all of the component
|
|
31 |
architecture and connecting to the database.
|
|
32 |
"""
|
|
33 |
self.main() |
|
5849.2.4
by Michael Hudson
stuff |
34 |
|
35 |
def main(self): |
|
36 |
globalErrorUtility.configure('codeimportdispatcher') |
|
37 |
||
10330.2.4
by Michael Hudson
ok, this actually works |
38 |
dispatcher = CodeImportDispatcher(self.logger, self.options.max_jobs) |
10356.1.4
by Michael Hudson
docstrings, and the important bit :-) |
39 |
dispatcher.findAndDispatchJobs( |
5849.2.18
by michael.hudson at canonical
review comments |
40 |
ServerProxy(config.codeimportdispatcher.codeimportscheduler_url)) |
5849.2.4
by Michael Hudson
stuff |
41 |
|
42 |
||
43 |
if __name__ == '__main__': |
|
6224.1.1
by Michael Hudson
Move database code from the dispatcher to ICodeImportJobSet.getJobForMachine. |
44 |
script = CodeImportDispatcherScript("codeimportdispatcher") |
5849.2.4
by Michael Hudson
stuff |
45 |
script.lock_and_run() |
46 |