~launchpad-pqm/launchpad/devel

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).
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
14612.2.8 by William Grant
cronscripts
17
7675.61.3 by Bjorn Tillenius
Undo the commit that removed all db changes.
18
from zope.component import getUtility
19
14612.2.8 by William Grant
cronscripts
20
from lp.code.interfaces.branchjob import IRosettaUploadJobSource
21
from lp.codehosting.vfs.branchfs import get_ro_server
14605.1.1 by Curtis Hovey
Moved canonical.config to lp.services.
22
from lp.services.config import config
8356.1.19 by Leonard Richardson
Moved the job runner into lp.services.job.
23
from lp.services.job.runner import JobRunner
8356.1.1 by Leonard Richardson
Partial move.
24
from lp.services.scripts.base import LaunchpadCronScript
14600.2.2 by Curtis Hovey
Moved webapp to lp.services.
25
from lp.services.webapp.errorlog import globalErrorUtility
7675.61.3 by Bjorn Tillenius
Undo the commit that removed all db changes.
26
27
28
class RunRosettaBranchJobs(LaunchpadCronScript):
29
    """Run pending branch translations jobs."""
30
31
    def main(self):
7675.108.2 by Henning Eggers
Use config in cronscript.
32
        globalErrorUtility.configure('rosettabranches')
9314.1.9 by Aaron Bentley
rosetta-branches logs oopses
33
        runner = JobRunner.fromReady(
34
            getUtility(IRosettaUploadJobSource), self.logger)
9590.1.119 by Michael Hudson
kill off get_scanner_server
35
        server = get_ro_server()
10197.5.13 by Michael Hudson
misc. fixes
36
        server.start_server()
7675.61.3 by Bjorn Tillenius
Undo the commit that removed all db changes.
37
        try:
38
            runner.runAll()
39
        finally:
10197.5.13 by Michael Hudson
misc. fixes
40
            server.stop_server()
7675.89.1 by Henning Eggers
Using logger and avoiding a warning about NULL_REVISON.
41
        self.logger.info('Ran %d RosettaBranchJobs.',
42
                         len(runner.completed_jobs))
7675.61.3 by Bjorn Tillenius
Undo the commit that removed all db changes.
43
44
45
if __name__ == '__main__':
7675.108.2 by Henning Eggers
Use config in cronscript.
46
    script = RunRosettaBranchJobs('rosettabranches',
47
                                  config.rosettabranches.dbuser)
7675.61.3 by Bjorn Tillenius
Undo the commit that removed all db changes.
48
    script.lock_and_run()