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
35
36
37
|
#!/usr/bin/python -S
#
# Copyright 2009 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
# pylint: disable-msg=C0103,W0403
"""Fetches mail from the mail box and feeds them to the handlers."""
import _pythonpath
from zope.component.interfaces import ComponentLookupError
from canonical.config import config
from lp.services.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)
|