summaryrefslogtreecommitdiff
path: root/Mailman/Queue
diff options
context:
space:
mode:
authorbwarsaw2006-04-17 04:08:17 +0000
committerbwarsaw2006-04-17 04:08:17 +0000
commit0ed815a216c7bb6f820cfdf99fc8d31bcfd19fc0 (patch)
tree7b710a785331abfe28b5b46a7695e6cbd81b7794 /Mailman/Queue
parent9934c9b2b0e76a0b77b7869ecf68cd960d4d5bd7 (diff)
downloadmailman-0ed815a216c7bb6f820cfdf99fc8d31bcfd19fc0.tar.gz
mailman-0ed815a216c7bb6f820cfdf99fc8d31bcfd19fc0.tar.zst
mailman-0ed815a216c7bb6f820cfdf99fc8d31bcfd19fc0.zip
Diffstat (limited to 'Mailman/Queue')
-rw-r--r--Mailman/Queue/BounceRunner.py34
-rw-r--r--Mailman/Queue/CommandRunner.py16
-rw-r--r--Mailman/Queue/IncomingRunner.py19
-rw-r--r--Mailman/Queue/MaildirRunner.py19
-rw-r--r--Mailman/Queue/NewsRunner.py15
-rw-r--r--Mailman/Queue/OutgoingRunner.py10
-rw-r--r--Mailman/Queue/Runner.py23
-rw-r--r--Mailman/Queue/Switchboard.py3
8 files changed, 74 insertions, 65 deletions
diff --git a/Mailman/Queue/BounceRunner.py b/Mailman/Queue/BounceRunner.py
index cb125ef58..0063635ac 100644
--- a/Mailman/Queue/BounceRunner.py
+++ b/Mailman/Queue/BounceRunner.py
@@ -21,23 +21,26 @@ import os
import re
import time
import cPickle
+import logging
from email.MIMEMessage import MIMEMessage
from email.MIMEText import MIMEText
from email.Utils import parseaddr
from Mailman import LockFile
-from Mailman import Utils
from Mailman import mm_cfg
+from Mailman import Utils
from Mailman.Bouncers import BouncerAPI
-from Mailman.Logging.Syslog import syslog
+from Mailman.i18n import _
from Mailman.Message import UserNotification
from Mailman.Queue.Runner import Runner
from Mailman.Queue.sbcache import get_switchboard
-from Mailman.i18n import _
COMMASPACE = ', '
+log = logging.getLogger('mailman.bounce')
+elog = logging.getLogger('mailman.error')
+
class BounceMixin:
@@ -96,8 +99,7 @@ class BounceMixin:
self._bouncecnt += len(addrs)
def _register_bounces(self):
- syslog('bounce', '%s processing %s queued bounces',
- self, self._bouncecnt)
+ log.info('%s processing %s queued bounces', self, self._bouncecnt)
# Read all the records from the bounce file, then unlink it. Sort the
# records by listname for more efficient processing.
events = {}
@@ -106,7 +108,7 @@ class BounceMixin:
try:
listname, addr, day, msg = cPickle.load(self._bounce_events_fp)
except ValueError, e:
- syslog('bounce', 'Error reading bounce events: %s', e)
+ log.error('Error reading bounce events: %s', e)
except EOFError:
break
events.setdefault(listname, []).append((addr, day, msg))
@@ -210,8 +212,8 @@ class BounceRunner(Runner, BounceMixin):
# If that still didn't return us any useful addresses, then send it on
# or discard it.
if not addrs:
- syslog('bounce', 'bounce message w/no discernable addresses: %s',
- msg.get('message-id'))
+ log.info('bounce message w/no discernable addresses: %s',
+ msg.get('message-id'))
maybe_forward(mlist, msg)
return
# BAW: It's possible that there are None's in the list of addresses,
@@ -252,9 +254,8 @@ def verp_bounce(mlist, msg):
# All is good
addr = '%s@%s' % mo.group('mailbox', 'host')
except IndexError:
- syslog('error',
- "VERP_REGEXP doesn't yield the right match groups: %s",
- mm_cfg.VERP_REGEXP)
+ elog.error("VERP_REGEXP doesn't yield the right match groups: %s",
+ mm_cfg.VERP_REGEXP)
return []
return [addr]
@@ -287,8 +288,7 @@ def verp_probe(mlist, msg):
if data is not None:
return token
except IndexError:
- syslog(
- 'error',
+ elog.error(
"VERP_PROBE_REGEXP doesn't yield the right match groups: %s",
mm_cfg.VERP_PROBE_REGEXP)
return None
@@ -313,8 +313,8 @@ For more information see:
"""),
subject=_('Uncaught bounce notification'),
tomoderators=0)
- syslog('bounce', 'forwarding unrecognized, message-id: %s',
- msg.get('message-id', 'n/a'))
+ log.error('forwarding unrecognized, message-id: %s',
+ msg.get('message-id', 'n/a'))
else:
- syslog('bounce', 'discarding unrecognized, message-id: %s',
- msg.get('message-id', 'n/a'))
+ log.error('discarding unrecognized, message-id: %s',
+ msg.get('message-id', 'n/a'))
diff --git a/Mailman/Queue/CommandRunner.py b/Mailman/Queue/CommandRunner.py
index 64b8f0758..978cb05cd 100644
--- a/Mailman/Queue/CommandRunner.py
+++ b/Mailman/Queue/CommandRunner.py
@@ -21,10 +21,9 @@
# bounce messages (i.e. -admin or -bounces), nor does it handle mail to
# -owner.
-
-
import re
import sys
+import logging
from email.Errors import HeaderParseError
from email.Header import decode_header, make_header, Header
@@ -35,15 +34,16 @@ from types import StringType, UnicodeType
from Mailman import LockFile
from Mailman import Message
-from Mailman import Utils
from Mailman import mm_cfg
+from Mailman import Utils
from Mailman.Handlers import Replybot
-from Mailman.Logging.Syslog import syslog
-from Mailman.Queue.Runner import Runner
from Mailman.i18n import _
+from Mailman.Queue.Runner import Runner
NL = '\n'
+log = logging.getLogger('mailman.vette')
+
class Results:
@@ -202,14 +202,14 @@ class CommandRunner(Runner):
precedence = msg.get('precedence', '').lower()
ack = msg.get('x-ack', '').lower()
if ack <> 'yes' and precedence in ('bulk', 'junk', 'list'):
- syslog('vette', 'Precedence: %s message discarded by: %s',
- precedence, mlist.GetRequestEmail())
+ log.info('Precedence: %s message discarded by: %s',
+ precedence, mlist.GetRequestEmail())
return False
# Do replybot for commands
mlist.Load()
Replybot.process(mlist, msg, msgdata)
if mlist.autorespond_requests == 1:
- syslog('vette', 'replied and discard')
+ log.info('replied and discard')
# w/discard
return False
# Now craft the response
diff --git a/Mailman/Queue/IncomingRunner.py b/Mailman/Queue/IncomingRunner.py
index 71d939197..19a315040 100644
--- a/Mailman/Queue/IncomingRunner.py
+++ b/Mailman/Queue/IncomingRunner.py
@@ -1,4 +1,4 @@
-# Copyright (C) 1998-2003 by the Free Software Foundation, Inc.
+# Copyright (C) 1998-2006 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -93,16 +93,21 @@
# performed. Results notifications are sent to the author of the message,
# which all bounces pointing back to the -bounces address.
+
-import sys
import os
+import sys
+import logging
+
from cStringIO import StringIO
-from Mailman import mm_cfg
from Mailman import Errors
from Mailman import LockFile
+from Mailman import mm_cfg
from Mailman.Queue.Runner import Runner
-from Mailman.Logging.Syslog import syslog
+
+log = logging.getLogger('mailman.error')
+vlog = logging.getLogger('mailman.vette')
@@ -153,12 +158,12 @@ class IncomingRunner(Runner):
sys.modules[modname].process(mlist, msg, msgdata)
# Failsafe -- a child may have leaked through.
if pid <> os.getpid():
- syslog('error', 'child process leaked thru: %s', modname)
+ log.error('child process leaked thru: %s', modname)
os._exit(1)
except Errors.DiscardMessage:
# Throw the message away; we need do nothing else with it.
- syslog('vette', 'Message discarded, msgid: %s',
- msg.get('message-id', 'n/a'))
+ vlog.info('Message discarded, msgid: %s',
+ msg.get('message-id', 'n/a'))
return 0
except Errors.HoldMessage:
# Let the approval process take it from here. The message no
diff --git a/Mailman/Queue/MaildirRunner.py b/Mailman/Queue/MaildirRunner.py
index 39971ae2a..97b71c7ef 100644
--- a/Mailman/Queue/MaildirRunner.py
+++ b/Mailman/Queue/MaildirRunner.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2002 by the Free Software Foundation, Inc.
+# Copyright (C) 2002-2006 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -12,7 +12,8 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
"""Maildir pre-queue runner.
@@ -51,6 +52,7 @@ mechanism.
import os
import re
import errno
+import logging
from email.Parser import Parser
from email.Utils import parseaddr
@@ -60,7 +62,6 @@ from Mailman import Utils
from Mailman.Message import Message
from Mailman.Queue.Runner import Runner
from Mailman.Queue.sbcache import get_switchboard
-from Mailman.Logging.Syslog import syslog
# We only care about the listname and the subq as in listname@ or
# listname-request@
@@ -73,6 +74,8 @@ lre = re.compile(r"""
)? # if it exists
""", re.VERBOSE | re.IGNORECASE)
+log = logging.getLogger('mailman.error')
+
class MaildirRunner(Runner):
@@ -110,7 +113,7 @@ class MaildirRunner(Runner):
if e.errno == errno.ENOENT:
# Some other MaildirRunner beat us to it
continue
- syslog('error', 'Could not rename maildir file: %s', srcname)
+ log.error('Could not rename maildir file: %s', srcname)
raise
# Now open, read, parse, and enqueue this message
try:
@@ -139,8 +142,8 @@ class MaildirRunner(Runner):
else:
# As far as we can tell, this message isn't destined for
# any list on the system. What to do?
- syslog('error', 'Message apparently not for any list: %s',
- xdstname)
+ log.error('Message apparently not for any list: %s',
+ xdstname)
os.rename(dstname, xdstname)
continue
# BAW: blech, hardcoded
@@ -171,14 +174,14 @@ class MaildirRunner(Runner):
msgdata['torequest'] = 1
queue = get_switchboard(mm_cfg.CMDQUEUE_DIR)
else:
- syslog('error', 'Unknown sub-queue: %s', subq)
+ log.error('Unknown sub-queue: %s', subq)
os.rename(dstname, xdstname)
continue
queue.enqueue(msg, msgdata)
os.unlink(dstname)
except Exception, e:
os.rename(dstname, xdstname)
- syslog('error', str(e))
+ log.error('%s', e)
def _cleanup(self):
pass
diff --git a/Mailman/Queue/NewsRunner.py b/Mailman/Queue/NewsRunner.py
index fa0e91377..7a71f5bf2 100644
--- a/Mailman/Queue/NewsRunner.py
+++ b/Mailman/Queue/NewsRunner.py
@@ -19,6 +19,7 @@
import re
import email
import socket
+import logging
import nntplib
from cStringIO import StringIO
@@ -26,11 +27,11 @@ from email.Utils import getaddresses
COMMASPACE = ', '
-from Mailman import Utils
from Mailman import mm_cfg
-from Mailman.Logging.Syslog import syslog
+from Mailman import Utils
from Mailman.Queue.Runner import Runner
+log = logging.getLogger('mailman.error')
# Matches our Mailman crafted Message-IDs. See Utils.unique_message_id()
mcre = re.compile(r"""
@@ -67,13 +68,11 @@ class NewsRunner(Runner):
password=mm_cfg.NNTP_PASSWORD)
conn.post(fp)
except nntplib.error_temp, e:
- syslog('error',
- '(NNTPDirect) NNTP error for list "%s": %s',
- mlist.internal_name(), e)
+ log.error('(NNTPDirect) NNTP error for list "%s": %s',
+ mlist.internal_name(), e)
except socket.error, e:
- syslog('error',
- '(NNTPDirect) socket error for list "%s": %s',
- mlist.internal_name(), e)
+ log.error('(NNTPDirect) socket error for list "%s": %s',
+ mlist.internal_name(), e)
finally:
if conn:
conn.quit()
diff --git a/Mailman/Queue/OutgoingRunner.py b/Mailman/Queue/OutgoingRunner.py
index a4a83000a..3d4575ed2 100644
--- a/Mailman/Queue/OutgoingRunner.py
+++ b/Mailman/Queue/OutgoingRunner.py
@@ -22,12 +22,12 @@ import copy
import time
import email
import socket
+import logging
from Mailman import Errors
from Mailman import LockFile
from Mailman import Message
from Mailman import mm_cfg
-from Mailman.Logging.Syslog import syslog
from Mailman.Queue.BounceRunner import BounceMixin
from Mailman.Queue.Runner import Runner
from Mailman.Queue.Switchboard import Switchboard
@@ -36,6 +36,8 @@ from Mailman.Queue.Switchboard import Switchboard
# permanent failures. It is a count of calls to _doperiodic()
DEAL_WITH_PERMFAILURES_EVERY = 10
+log = logging.getLogger('mailman.error')
+
class OutgoingRunner(Runner, BounceMixin):
@@ -66,7 +68,7 @@ class OutgoingRunner(Runner, BounceMixin):
self._func(mlist, msg, msgdata)
# Failsafe -- a child may have leaked through.
if pid <> os.getpid():
- syslog('error', 'child process leaked thru: %s', modname)
+ log.error('child process leaked thru: %s', modname)
os._exit(1)
self.__logged = False
except socket.error:
@@ -78,8 +80,8 @@ class OutgoingRunner(Runner, BounceMixin):
port = 'smtp'
# Log this just once.
if not self.__logged:
- syslog('error', 'Cannot connect to SMTP server %s on port %s',
- mm_cfg.SMTPHOST, port)
+ log.error('Cannot connect to SMTP server %s on port %s',
+ mm_cfg.SMTPHOST, port)
self.__logged = True
return True
except Errors.SomeRecipientsFailed, e:
diff --git a/Mailman/Queue/Runner.py b/Mailman/Queue/Runner.py
index 7c99c50a5..56baf431b 100644
--- a/Mailman/Queue/Runner.py
+++ b/Mailman/Queue/Runner.py
@@ -19,18 +19,20 @@
import time
import weakref
import traceback
+import logging
import email.Errors
from cStringIO import StringIO
from Mailman import Errors
-from Mailman import MailList
-from Mailman import Utils
from Mailman import i18n
+from Mailman import MailList
from Mailman import mm_cfg
-from Mailman.Logging.Syslog import syslog
+from Mailman import Utils
from Mailman.Queue.Switchboard import Switchboard
+log = logging.getLogger('mailman.error')
+
class Runner:
@@ -97,7 +99,7 @@ class Runner:
# There's not much we can do (and we didn't even get the
# metadata, so just log the exception and continue.
self._log(e)
- syslog('error', 'Ignoring unparseable message: %s', filebase)
+ log.error('Ignoring unparseable message: %s', filebase)
continue
try:
self._onefile(msg, msgdata)
@@ -112,7 +114,7 @@ class Runner:
# Put a marker in the metadata for unshunting
msgdata['whichq'] = self._switchboard.whichq()
filebase = self._shunt.enqueue(msg, msgdata)
- syslog('error', 'SHUNTING: %s', filebase)
+ log.error('SHUNTING: %s', filebase)
# Other work we want to do each time through the loop
Utils.reap(self._kids, once=True)
self._doperiodic()
@@ -133,9 +135,8 @@ class Runner:
listname = mm_cfg.MAILMAN_SITE_LIST
mlist = self._open_list(listname)
if not mlist:
- syslog('error',
- 'Dequeuing message destined for missing list: %s',
- listname)
+ log.error('Dequeuing message destined for missing list: %s',
+ listname)
self._shunt.enqueue(msg, msgdata)
return
# Now process this message, keeping track of any subprocesses that may
@@ -178,17 +179,17 @@ class Runner:
try:
mlist = MailList.MailList(listname, lock=False)
except Errors.MMListError, e:
- syslog('error', 'error opening list: %s\n%s', listname, e)
+ log.error('error opening list: %s\n%s', listname, e)
return None
else:
self._listcache[listname] = mlist
return mlist
def _log(self, exc):
- syslog('error', 'Uncaught runner exception: %s', exc)
+ log.error('Uncaught runner exception: %s', exc)
s = StringIO()
traceback.print_exc(file=s)
- syslog('error', s.getvalue())
+ log.error('%s', s.getvalue())
#
# Subclasses can override these methods.
diff --git a/Mailman/Queue/Switchboard.py b/Mailman/Queue/Switchboard.py
index 33177ba8b..36b69283e 100644
--- a/Mailman/Queue/Switchboard.py
+++ b/Mailman/Queue/Switchboard.py
@@ -41,9 +41,8 @@ import cPickle
import marshal
from Mailman import Message
-from Mailman import Utils
from Mailman import mm_cfg
-from Mailman.Logging.Syslog import syslog
+from Mailman import Utils
# 20 bytes of all bits set, maximum sha.digest() value
shamax = 0xffffffffffffffffffffffffffffffffffffffffL