1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#!/usr/bin/python2.4
# Copyright 2004-2007 Canonical Ltd. All rights reserved.
# pylint: disable-msg=C0103,W0403
"""Fetches mail from the mail box and feeds them to the handlers."""
import _pythonpath
from zope.component.exceptions import ComponentLookupError
from canonical.config import config
from canonical.launchpad.scripts.base import (
LaunchpadCronScript, LaunchpadScriptFailure)
from canonical.launchpad.mail.incoming import handleMail
from canonical.launchpad.interfaces import IMailBox
class ProcessMail(LaunchpadCronScript):
usage = """%prog [options]
""" + __doc__
def main(self):
try:
handleMail(self.txn)
except ComponentLookupError, lookup_error:
if lookup_error.args[0] != IMailBox:
raise
raise LaunchpadScriptFailure(
"No mail box is configured. "
"Please see mailbox.txt for info on how to configure one.")
if __name__ == '__main__':
script = ProcessMail('process-mail', dbuser=config.processmail.dbuser)
script.lock_and_run(use_web_security=True)
|