~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
17
from zope.component import getUtility
18
19
from canonical.config import config
9590.1.119 by Michael Hudson
kill off get_scanner_server
20
from lp.codehosting.vfs.branchfs import get_ro_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
14600.2.2 by Curtis Hovey
Moved webapp to lp.services.
24
from lp.services.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)
9590.1.119 by Michael Hudson
kill off get_scanner_server
34
        server = get_ro_server()
10197.5.13 by Michael Hudson
misc. fixes
35
        server.start_server()
7675.61.3 by Bjorn Tillenius
Undo the commit that removed all db changes.
36
        try:
37
            runner.runAll()
38
        finally:
10197.5.13 by Michael Hudson
misc. fixes
39
            server.stop_server()
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()