~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)
11678.2.5 by Gary Poster
move files as requested by review to lp/services; change things further as lint requests.
16
from lp.services.mail.incoming import handleMail
11882.2.2 by Jonathan Lange
Clear up a heck of a lot of imports from canonical.launchpad.interfaces.
17
from canonical.launchpad.interfaces.mailbox import IMailBox
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
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__
11678.2.5 by Gary Poster
move files as requested by review to lp/services; change things further as lint requests.
24
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
    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
26
        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...
27
            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
28
        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...
29
            if lookup_error.args[0] != IMailBox:
30
                raise
31
            raise LaunchpadScriptFailure(
32
                "No mail box is configured. "
33
                "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
34
35
36
if __name__ == '__main__':
4974.5.4 by Francis J. Lacoste
Make process-mail.py dbuser configurable.
37
    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...
38
    script.lock_and_run(use_web_security=True)