~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
13
from zope.component import getUtility
14
15
from canonical.config import config
8356.1.19 by Leonard Richardson
Moved the job runner into lp.services.job.
16
from lp.services.job.runner import JobRunner
8138.1.2 by Jonathan Lange
Run migrater over lp.code. Many tests broken and imports failing.
17
from lp.code.interfaces.branchmergeproposal import (
7659.3.12 by Aaron Bentley
Process merge proposal creation jobs via script
18
    ICreateMergeProposalJobSource,)
8356.1.1 by Leonard Richardson
Partial move.
19
from lp.services.scripts.base import LaunchpadCronScript
14600.2.2 by Curtis Hovey
Moved webapp to lp.services.
20
from lp.services.webapp.errorlog import globalErrorUtility
7659.3.12 by Aaron Bentley
Process merge proposal creation jobs via script
21
22
23
class RunCreateMergeProposalJobs(LaunchpadCronScript):
24
    """Run create merge proposal jobs."""
25
26
    def main(self):
7659.3.14 by Aaron Bentley
Misc cleanup
27
        globalErrorUtility.configure('create_merge_proposals')
7659.3.12 by Aaron Bentley
Process merge proposal creation jobs via script
28
        job_source = getUtility(ICreateMergeProposalJobSource)
9314.1.7 by Aaron Bentley
create_merge_proposals reports oopses.
29
        runner = JobRunner.fromReady(job_source, self.logger)
7675.60.2 by Aaron Bentley
Get signatures properly tested.
30
        runner.runAll()
31
        self.logger.info(
32
            'Ran %d CreateMergeProposalJobs.' % len(runner.completed_jobs))
7659.3.12 by Aaron Bentley
Process merge proposal creation jobs via script
33
34
35
if __name__ == '__main__':
36
    script = RunCreateMergeProposalJobs(
7659.3.14 by Aaron Bentley
Misc cleanup
37
        'create_merge_proposals', config.create_merge_proposals.dbuser)
7659.3.12 by Aaron Bentley
Process merge proposal creation jobs via script
38
    script.lock_and_run()