~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
7659.3.12 by Aaron Bentley
Process merge proposal creation jobs via script
6
# pylint: disable-msg=W0403
7
8
"""Create BranchMergeProposals from email."""
9
10
__metaclass__ = type
11
12
import _pythonpath
14612.2.8 by William Grant
cronscripts
13
7659.3.12 by Aaron Bentley
Process merge proposal creation jobs via script
14
from zope.component import getUtility
15
14612.2.8 by William Grant
cronscripts
16
from lp.code.interfaces.branchmergeproposal import (
17
    ICreateMergeProposalJobSource,
18
    )
14605.1.1 by Curtis Hovey
Moved canonical.config to lp.services.
19
from lp.services.config import config
8356.1.19 by Leonard Richardson
Moved the job runner into lp.services.job.
20
from lp.services.job.runner import JobRunner
8356.1.1 by Leonard Richardson
Partial move.
21
from lp.services.scripts.base import LaunchpadCronScript
14600.2.2 by Curtis Hovey
Moved webapp to lp.services.
22
from lp.services.webapp.errorlog import globalErrorUtility
7659.3.12 by Aaron Bentley
Process merge proposal creation jobs via script
23
24
25
class RunCreateMergeProposalJobs(LaunchpadCronScript):
26
    """Run create merge proposal jobs."""
27
28
    def main(self):
7659.3.14 by Aaron Bentley
Misc cleanup
29
        globalErrorUtility.configure('create_merge_proposals')
7659.3.12 by Aaron Bentley
Process merge proposal creation jobs via script
30
        job_source = getUtility(ICreateMergeProposalJobSource)
9314.1.7 by Aaron Bentley
create_merge_proposals reports oopses.
31
        runner = JobRunner.fromReady(job_source, self.logger)
7675.60.2 by Aaron Bentley
Get signatures properly tested.
32
        runner.runAll()
33
        self.logger.info(
34
            'Ran %d CreateMergeProposalJobs.' % len(runner.completed_jobs))
7659.3.12 by Aaron Bentley
Process merge proposal creation jobs via script
35
36
37
if __name__ == '__main__':
38
    script = RunCreateMergeProposalJobs(
7659.3.14 by Aaron Bentley
Misc cleanup
39
        'create_merge_proposals', config.create_merge_proposals.dbuser)
7659.3.12 by Aaron Bentley
Process merge proposal creation jobs via script
40
    script.lock_and_run()