~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
4935.3.7 by Curtis Hovey
Added bad name suppression to cronscripts.
6
# pylint: disable-msg=C0103,W0403
1872 by Canonical.com Patch Queue Manager
First cut of the email interface! Refactorings to SQLObjectFooEvents. First cut of banzai deeath scene. Fix bug 931. Add bug url declarations. And some more... r=stevea
7
"""Fetches mail from the mail box and feeds them to the handlers."""
8
2125 by Canonical.com Patch Queue Manager
[r=bjornt] Cronscript refactorings
9
import _pythonpath
10
7225.1.1 by Danilo Šegan
Fix #284665: do not use deprecated zope.component.exceptions, and instead use zope.component.interfaces to get ComponentLookupError.
11
from zope.component.interfaces import ComponentLookupError
1872 by Canonical.com Patch Queue Manager
First cut of the email interface! Refactorings to SQLObjectFooEvents. First cut of banzai deeath scene. Fix bug 931. Add bug url declarations. And some more... r=stevea
12
4974.5.4 by Francis J. Lacoste
Make process-mail.py dbuser configurable.
13
from canonical.config import config
8356.1.1 by Leonard Richardson
Partial move.
14
from lp.services.scripts.base import (
4264.2.1 by James Henstridge
add a LaunchpadCronScript subclass, and make cronscripts/*.py use it
15
    LaunchpadCronScript, LaunchpadScriptFailure)
1872 by Canonical.com Patch Queue Manager
First cut of the email interface! Refactorings to SQLObjectFooEvents. First cut of banzai deeath scene. Fix bug 931. Add bug url declarations. And some more... r=stevea
16
from canonical.launchpad.mail.incoming import handleMail
17
from canonical.launchpad.interfaces import IMailBox
18
4974.5.4 by Francis J. Lacoste
Make process-mail.py dbuser configurable.
19
4264.2.1 by James Henstridge
add a LaunchpadCronScript subclass, and make cronscripts/*.py use it
20
class ProcessMail(LaunchpadCronScript):
3691.348.18 by kiko
Convert most other scripts; 6 remain, of which one looks like it's going to be a bit tricky...
21
    usage = """%prog [options]
22
23
    """ + __doc__
24
    def main(self):
1872 by Canonical.com Patch Queue Manager
First cut of the email interface! Refactorings to SQLObjectFooEvents. First cut of banzai deeath scene. Fix bug 931. Add bug url declarations. And some more... r=stevea
25
        try:
3691.348.18 by kiko
Convert most other scripts; 6 remain, of which one looks like it's going to be a bit tricky...
26
            handleMail(self.txn)
1872 by Canonical.com Patch Queue Manager
First cut of the email interface! Refactorings to SQLObjectFooEvents. First cut of banzai deeath scene. Fix bug 931. Add bug url declarations. And some more... r=stevea
27
        except ComponentLookupError, lookup_error:
3691.348.18 by kiko
Convert most other scripts; 6 remain, of which one looks like it's going to be a bit tricky...
28
            if lookup_error.args[0] != IMailBox:
29
                raise
30
            raise LaunchpadScriptFailure(
31
                "No mail box is configured. "
32
                "Please see mailbox.txt for info on how to configure one.")
1872 by Canonical.com Patch Queue Manager
First cut of the email interface! Refactorings to SQLObjectFooEvents. First cut of banzai deeath scene. Fix bug 931. Add bug url declarations. And some more... r=stevea
33
34
35
if __name__ == '__main__':
4974.5.4 by Francis J. Lacoste
Make process-mail.py dbuser configurable.
36
    script = ProcessMail('process-mail', dbuser=config.processmail.dbuser)
3691.348.18 by kiko
Convert most other scripts; 6 remain, of which one looks like it's going to be a bit tricky...
37
    script.lock_and_run(use_web_security=True)