9678.4.1
by Max Bowsher
[r=barry][ui=none] Update Makefile PYTHON_VERSION variables and most script #! lines to python2.5. |
1 |
#!/usr/bin/python2.5
|
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).
|
|
5 |
||
7675.61.3
by Bjorn Tillenius
Undo the commit that removed all db changes. |
6 |
# pylint: disable-msg=W0403
|
7 |
||
8 |
"""Process branches with translation to import.
|
|
9 |
||
10 |
This script processes code branches that have new translations imports
|
|
11 |
pending.
|
|
12 |
"""
|
|
13 |
||
14 |
__metaclass__ = type |
|
15 |
||
16 |
import _pythonpath |
|
17 |
from zope.component import getUtility |
|
18 |
||
19 |
from canonical.config import config |
|
8426.6.1
by Michael Hudson
bzr ls --versioned --recursive --kind=file | xargs sed -i -e 's,from canonical.codehosting,from lp.codehosting,' |
20 |
from lp.codehosting.vfs.branchfs import get_scanner_server |
8356.1.19
by Leonard Richardson
Moved the job runner into lp.services.job. |
21 |
from lp.services.job.runner import JobRunner |
8138.1.2
by Jonathan Lange
Run migrater over lp.code. Many tests broken and imports failing. |
22 |
from lp.code.interfaces.branchjob import IRosettaUploadJobSource |
8356.1.1
by Leonard Richardson
Partial move. |
23 |
from lp.services.scripts.base import LaunchpadCronScript |
7675.108.4
by Henning Eggers
Added missing import. |
24 |
from canonical.launchpad.webapp.errorlog import globalErrorUtility |
7675.61.3
by Bjorn Tillenius
Undo the commit that removed all db changes. |
25 |
|
26 |
||
27 |
class RunRosettaBranchJobs(LaunchpadCronScript): |
|
28 |
"""Run pending branch translations jobs."""
|
|
29 |
||
30 |
def main(self): |
|
7675.108.2
by Henning Eggers
Use config in cronscript. |
31 |
globalErrorUtility.configure('rosettabranches') |
9314.1.9
by Aaron Bentley
rosetta-branches logs oopses |
32 |
runner = JobRunner.fromReady( |
33 |
getUtility(IRosettaUploadJobSource), self.logger) |
|
7675.61.3
by Bjorn Tillenius
Undo the commit that removed all db changes. |
34 |
server = get_scanner_server() |
35 |
server.setUp() |
|
36 |
try: |
|
37 |
runner.runAll() |
|
38 |
finally: |
|
39 |
server.tearDown() |
|
7675.89.1
by Henning Eggers
Using logger and avoiding a warning about NULL_REVISON. |
40 |
self.logger.info('Ran %d RosettaBranchJobs.', |
41 |
len(runner.completed_jobs)) |
|
7675.61.3
by Bjorn Tillenius
Undo the commit that removed all db changes. |
42 |
|
43 |
||
44 |
if __name__ == '__main__': |
|
7675.108.2
by Henning Eggers
Use config in cronscript. |
45 |
script = RunRosettaBranchJobs('rosettabranches', |
46 |
config.rosettabranches.dbuser) |
|
7675.61.3
by Bjorn Tillenius
Undo the commit that removed all db changes. |
47 |
script.lock_and_run() |