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 |
#
|
13463.2.1
by William Grant
Revert r13420 (the relanding of r13292, which broke production in similar ways). |
3 |
# Copyright 2009 Canonical Ltd. This software is licensed under the
|
8687.15.7
by Karl Fogel
Add the copyright header block to more files. |
4 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
5 |
||
6805.19.67
by Aaron Bentley
Suppress lint warning (as per other scripts) |
6 |
# pylint: disable-msg=W0403
|
6805.19.8
by Aaron Bentley
Add script to run code emails |
7 |
|
6805.19.42
by Aaron Bentley
Initial work on running mail jobs |
8 |
"""Send branch mail.
|
6805.19.8
by Aaron Bentley
Add script to run code emails |
9 |
|
10 |
This script sends out all the mail jobs that are pending.
|
|
11 |
"""
|
|
12 |
||
13 |
__metaclass__ = type |
|
14 |
||
15 |
import _pythonpath |
|
14612.2.8
by William Grant
cronscripts |
16 |
|
13463.2.1
by William Grant
Revert r13420 (the relanding of r13292, which broke production in similar ways). |
17 |
from zope.component import getUtility |
6805.19.8
by Aaron Bentley
Add script to run code emails |
18 |
|
14612.2.8
by William Grant
cronscripts |
19 |
from lp.code.interfaces.branchjob import ( |
20 |
IRevisionMailJobSource, |
|
21 |
IRevisionsAddedJobSource, |
|
22 |
)
|
|
23 |
from lp.codehosting.vfs import get_ro_server |
|
14605.1.1
by Curtis Hovey
Moved canonical.config to lp.services. |
24 |
from lp.services.config import config |
13463.2.1
by William Grant
Revert r13420 (the relanding of r13292, which broke production in similar ways). |
25 |
from lp.services.job.runner import JobRunner |
8356.1.1
by Leonard Richardson
Partial move. |
26 |
from lp.services.scripts.base import LaunchpadCronScript |
14600.2.2
by Curtis Hovey
Moved webapp to lp.services. |
27 |
from lp.services.webapp.errorlog import globalErrorUtility |
6805.19.8
by Aaron Bentley
Add script to run code emails |
28 |
|
29 |
||
6805.19.42
by Aaron Bentley
Initial work on running mail jobs |
30 |
class RunRevisionMailJobs(LaunchpadCronScript): |
6805.19.46
by Aaron Bentley
Get sendbranchmail under test. |
31 |
"""Run pending branch mail jobs."""
|
6805.19.8
by Aaron Bentley
Add script to run code emails |
32 |
|
33 |
def main(self): |
|
6805.19.62
by Aaron Bentley
Update to use codejobrunner user and zopeless layer |
34 |
globalErrorUtility.configure('sendbranchmail') |
13463.2.1
by William Grant
Revert r13420 (the relanding of r13292, which broke production in similar ways). |
35 |
jobs = list(getUtility(IRevisionMailJobSource).iterReady()) |
36 |
jobs.extend(getUtility(IRevisionsAddedJobSource).iterReady()) |
|
37 |
runner = JobRunner(jobs, self.logger) |
|
38 |
server = get_ro_server() |
|
39 |
server.start_server() |
|
40 |
try: |
|
41 |
runner.runAll() |
|
42 |
finally: |
|
43 |
server.stop_server() |
|
7797.1.18
by Aaron Bentley
Output via logger instead of stdout |
44 |
self.logger.info( |
45 |
'Ran %d RevisionMailJobs.' % len(runner.completed_jobs)) |
|
6805.19.8
by Aaron Bentley
Add script to run code emails |
46 |
|
47 |
||
48 |
if __name__ == '__main__': |
|
7675.12.1
by Tim Penhey
Create explicit db users for every script. |
49 |
script = RunRevisionMailJobs( |
50 |
'sendbranchmail', config.sendbranchmail.dbuser) |
|
6805.19.62
by Aaron Bentley
Update to use codejobrunner user and zopeless layer |
51 |
script.lock_and_run() |