~launchpad-pqm/launchpad/devel

3944.1.1 by Francis J. Lacoste
Use system version python2.4 for scripts.
1
#!/usr/bin/python2.4
4974.5.4 by Francis J. Lacoste
Make process-mail.py dbuser configurable.
2
# Copyright 2004-2007 Canonical Ltd.  All rights reserved.
4935.3.7 by Curtis Hovey
Added bad name suppression to cronscripts.
3
# 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
4
"""Fetches mail from the mail box and feeds them to the handlers."""
5
2125 by Canonical.com Patch Queue Manager
[r=bjornt] Cronscript refactorings
6
import _pythonpath
7
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
8
from zope.component.exceptions import ComponentLookupError
9
4974.5.4 by Francis J. Lacoste
Make process-mail.py dbuser configurable.
10
from canonical.config import config
3691.348.18 by kiko
Convert most other scripts; 6 remain, of which one looks like it's going to be a bit tricky...
11
from canonical.launchpad.scripts.base import (
4264.2.1 by James Henstridge
add a LaunchpadCronScript subclass, and make cronscripts/*.py use it
12
    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
13
from canonical.launchpad.mail.incoming import handleMail
14
from canonical.launchpad.interfaces import IMailBox
15
4974.5.4 by Francis J. Lacoste
Make process-mail.py dbuser configurable.
16
4264.2.1 by James Henstridge
add a LaunchpadCronScript subclass, and make cronscripts/*.py use it
17
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...
18
    usage = """%prog [options]
19
20
    """ + __doc__
21
    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
22
        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...
23
            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
24
        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...
25
            if lookup_error.args[0] != IMailBox:
26
                raise
27
            raise LaunchpadScriptFailure(
28
                "No mail box is configured. "
29
                "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
30
31
32
if __name__ == '__main__':
4974.5.4 by Francis J. Lacoste
Make process-mail.py dbuser configurable.
33
    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...
34
    script.lock_and_run(use_web_security=True)