~sambuddhabasu1/mailman/fix_mailman_run_error

« back to all changes in this revision

Viewing changes to mailman/bin/request.py

  • Committer: Barry Warsaw
  • Date: 2009-01-21 01:54:22 UTC
  • Revision ID: barry@list.org-20090121015422-oko6qfipdm1a7l6x
More cleanup.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 1998-2009 by the Free Software Foundation, Inc.
2
 
#
3
 
# This file is part of GNU Mailman.
4
 
#
5
 
# GNU Mailman is free software: you can redistribute it and/or modify it under
6
 
# the terms of the GNU General Public License as published by the Free
7
 
# Software Foundation, either version 3 of the License, or (at your option)
8
 
# any later version.
9
 
#
10
 
# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
11
 
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
 
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13
 
# more details.
14
 
#
15
 
# You should have received a copy of the GNU General Public License along with
16
 
# GNU Mailman.  If not, see <http://www.gnu.org/licenses/>.
17
 
 
18
 
"""Process emailed commands.
19
 
 
20
 
Called by the wrapper, stdin is the mail message, and argv[1] is the name
21
 
of the target mailing list.
22
 
 
23
 
Errors are redirected to logs/error.
24
 
"""
25
 
 
26
 
import sys
27
 
import logging
28
 
 
29
 
from mailman import Utils
30
 
from mailman import loginit
31
 
from mailman.configuration import config
32
 
from mailman.i18n import _
33
 
from mailman.queue import Switchboard
34
 
 
35
 
 
36
 
 
37
 
def main():
38
 
    config.load()
39
 
    # Setup logging to stderr stream and error log.
40
 
    loginit.initialize(propagate=True)
41
 
    log = logging.getLogger('mailman.error')
42
 
    try:
43
 
        listname = sys.argv[1]
44
 
    except IndexError:
45
 
        log.error(_('request script got no listname.'))
46
 
        sys.exit(1)
47
 
    # Make sure the list exists
48
 
    if not Utils.list_exists(listname):
49
 
        log.error(_('request script, list not found: $listname'))
50
 
        sys.exit(1)
51
 
    # Immediately queue the message for the bounce/cmd qrunner to process.
52
 
    # The advantage to this approach is that messages should never get lost --
53
 
    # some MTAs have a hard limit to the time a filter prog can run.  Postfix
54
 
    # is a good example; if the limit is hit, the proc is SIGKILL'd giving us
55
 
    # no chance to save the message.
56
 
    cmdq = Switchboard(config.CMDQUEUE_DIR)
57
 
    cmdq.enqueue(sys.stdin.read(),
58
 
                 listname=listname,
59
 
                 torequest=True,
60
 
                 _plaintext=True)
61
 
 
62
 
 
63
 
 
64
 
if __name__ == '__main__':
65
 
    main()