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 |
||
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 |
|
16 |
from zope.component import getUtility |
|
17 |
||
6805.19.62
by Aaron Bentley
Update to use codejobrunner user and zopeless layer |
18 |
from canonical.config import config |
9590.1.119
by Michael Hudson
kill off get_scanner_server |
19 |
from lp.codehosting.vfs import get_ro_server |
8356.1.19
by Leonard Richardson
Moved the job runner into lp.services.job. |
20 |
from lp.services.job.runner import JobRunner |
8138.1.2
by Jonathan Lange
Run migrater over lp.code. Many tests broken and imports failing. |
21 |
from lp.code.interfaces.branchjob import ( |
7797.1.12
by Aaron Bentley
Get sendbranchmail doing RevisionsAddedJobs |
22 |
IRevisionMailJobSource, IRevisionsAddedJobSource) |
8356.1.1
by Leonard Richardson
Partial move. |
23 |
from lp.services.scripts.base import LaunchpadCronScript |
6805.19.62
by Aaron Bentley
Update to use codejobrunner user and zopeless layer |
24 |
from canonical.launchpad.webapp.errorlog import globalErrorUtility |
6805.19.8
by Aaron Bentley
Add script to run code emails |
25 |
|
26 |
||
6805.19.42
by Aaron Bentley
Initial work on running mail jobs |
27 |
class RunRevisionMailJobs(LaunchpadCronScript): |
6805.19.46
by Aaron Bentley
Get sendbranchmail under test. |
28 |
"""Run pending branch mail jobs."""
|
6805.19.8
by Aaron Bentley
Add script to run code emails |
29 |
|
30 |
def main(self): |
|
6805.19.62
by Aaron Bentley
Update to use codejobrunner user and zopeless layer |
31 |
globalErrorUtility.configure('sendbranchmail') |
7797.1.12
by Aaron Bentley
Get sendbranchmail doing RevisionsAddedJobs |
32 |
jobs = list(getUtility(IRevisionMailJobSource).iterReady()) |
33 |
jobs.extend(getUtility(IRevisionsAddedJobSource).iterReady()) |
|
9314.1.6
by Aaron Bentley
Log oopses for sendbranchmail. |
34 |
runner = JobRunner(jobs, 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() |
7646.1.1
by Aaron Bentley
Get test failing due to missing branch. |
37 |
try: |
38 |
runner.runAll() |
|
39 |
finally: |
|
10197.5.13
by Michael Hudson
misc. fixes |
40 |
server.stop_server() |
7797.1.18
by Aaron Bentley
Output via logger instead of stdout |
41 |
self.logger.info( |
42 |
'Ran %d RevisionMailJobs.' % len(runner.completed_jobs)) |
|
6805.19.8
by Aaron Bentley
Add script to run code emails |
43 |
|
44 |
||
45 |
if __name__ == '__main__': |
|
7675.12.1
by Tim Penhey
Create explicit db users for every script. |
46 |
script = RunRevisionMailJobs( |
47 |
'sendbranchmail', config.sendbranchmail.dbuser) |
|
6805.19.62
by Aaron Bentley
Update to use codejobrunner user and zopeless layer |
48 |
script.lock_and_run() |