diff options
| author | bwarsaw | 2006-04-24 03:55:29 +0000 |
|---|---|---|
| committer | bwarsaw | 2006-04-24 03:55:29 +0000 |
| commit | 155748d1c28457ce49dd6f67df24cd01285438a4 (patch) | |
| tree | dfa5e8ddcc0bad1a92a55a901c078d49071c3bc6 /cron | |
| parent | 93ffb008e4ce9b0655499f482da9613a229f68c8 (diff) | |
| download | mailman-155748d1c28457ce49dd6f67df24cd01285438a4.tar.gz mailman-155748d1c28457ce49dd6f67df24cd01285438a4.tar.zst mailman-155748d1c28457ce49dd6f67df24cd01285438a4.zip | |
Diffstat (limited to 'cron')
| -rw-r--r-- | cron/disabled | 32 | ||||
| -rwxr-xr-x | cron/gate_news | 77 |
2 files changed, 50 insertions, 59 deletions
diff --git a/cron/disabled b/cron/disabled index 6624ff21f..dfc88cdf5 100644 --- a/cron/disabled +++ b/cron/disabled @@ -1,6 +1,6 @@ #! @PYTHON@ # -# Copyright (C) 2001-2004 by the Free Software Foundation, Inc. +# Copyright (C) 2001-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 @@ -14,7 +14,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. """Process disabled members, recommended once per day. @@ -63,19 +64,21 @@ Options: import sys import time import getopt +import logging import paths # mm_cfg must be imported before the other modules, due to the side-effect of # it hacking sys.paths to include site-packages. Without this, running this # script from cron with python -S will fail. from Mailman import mm_cfg -from Mailman import Utils + +from Mailman import Errors from Mailman import MailList -from Mailman import Pending from Mailman import MemberAdaptor -from Mailman import Errors +from Mailman import Pending +from Mailman import Utils +from Mailman import loginit from Mailman.Bouncer import _BounceInfo -from Mailman.Logging.Syslog import syslog from Mailman.i18n import _ # Work around known problems with some RedHat cron daemons @@ -84,6 +87,10 @@ signal.signal(signal.SIGCHLD, signal.SIG_DFL) PROGRAM = sys.argv[0] +loginit.initialize(properly=True) +elog = logging.getLogger('mailman.error') +blog = logging.getLogger('mailman.bounce') + def usage(code, msg=''): @@ -181,8 +188,7 @@ def main(): # other reason. status = mlist.getDeliveryStatus(member) if status == MemberAdaptor.BYBOUNCE: - syslog( - 'error', + elog.error( '%s disabled BYBOUNCE lacks bounce info, list: %s', member, mlist.internal_name()) continue @@ -198,17 +204,17 @@ def main(): notify.append(member) # Now, send notifications to anyone who is due for member in notify: - syslog('bounce', 'Notifying disabled member %s for list: %s', - member, mlist.internal_name()) + blog.info('Notifying disabled member %s for list: %s', + member, mlist.internal_name()) try: mlist.sendNextNotification(member) except Errors.NotAMemberError: # There must have been some problem with the data we have # on this member. Most likely it's that they don't have a # password assigned. Log this and delete the member. - syslog('bounce', - 'NotAMemberError when sending disabled notice: %s', - member) + blog.info( + 'NotAMemberError when sending disabled notice: %s', + member) mlist.ApprovedDeleteMember(member, 'cron/disabled') mlist.Save() finally: diff --git a/cron/gate_news b/cron/gate_news index a84731f3f..f0701ca8b 100755 --- a/cron/gate_news +++ b/cron/gate_news @@ -1,6 +1,6 @@ #! @PYTHON@ # -# 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 @@ -14,7 +14,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. """Poll the NNTP servers for messages to be gatewayed to mailing lists. @@ -28,27 +29,31 @@ Where options are """ -import sys import os +import sys import time import getopt import socket +import logging import nntplib import paths +# mm_cfg must be imported before the other modules, due to the side-effect of +# it hacking sys.paths to include site-packages. Without this, running this +# script from cron with python -S will fail. +from Mailman import mm_cfg + # Import this /after/ paths so that the sys.path is properly hacked import email.Errors from email.Parser import Parser -from Mailman import mm_cfg +from Mailman import LockFile from Mailman import MailList -from Mailman import Utils from Mailman import Message -from Mailman import LockFile -from Mailman.i18n import _ +from Mailman import Utils +from Mailman import loginit from Mailman.Queue.sbcache import get_switchboard -from Mailman.Logging.Utils import LogStdErr -from Mailman.Logging.Syslog import syslog +from Mailman.i18n import _ # Work around known problems with some RedHat cron daemons import signal @@ -56,22 +61,11 @@ signal.signal(signal.SIGCHLD, signal.SIG_DFL) GATENEWS_LOCK_FILE = os.path.join(mm_cfg.LOCK_DIR, 'gate_news.lock') -LogStdErr('error', 'gate_news', manual_reprime=0) - LOCK_LIFETIME = mm_cfg.hours(2) NL = '\n' -# Continues inside try: block are not allowed in Python versions before 2.1. -# This exception is used to work around that. -class _ContinueLoop(Exception): - pass - - -try: - True, False -except NameError: - True = 1 - False = 0 +loginit.initialize(propagate=True) +log = logging.getLogger('mailman.fromusenet') @@ -102,9 +96,8 @@ def open_newsgroup(mlist): user=mm_cfg.NNTP_USERNAME, password=mm_cfg.NNTP_PASSWORD) except (socket.error, nntplib.NNTPError, IOError), e: - syslog('fromusenet', - 'error opening connection to nntp_host: %s\n%s', - mlist.nntp_host, e) + log.error('error opening connection to nntp_host: %s\n%s', + mlist.nntp_host, e) raise _hostcache[mlist.nntp_host] = conn # Get the GROUP information for the list, but we're only really interested @@ -162,9 +155,8 @@ def poll_newsgroup(mlist, conn, first, last, glock): try: msg = p.parsestr(NL.join(lines)) except email.Errors.MessageError, e: - syslog('fromusenet', - 'email package exception for %s:%d\n%s', - mlist.linked_newsgroup, num, e) + log.error('email package exception for %s:%d\n%s', + mlist.linked_newsgroup, num, e) raise _ContinueLoop if found_to: del msg['X-Originally-To'] @@ -176,12 +168,9 @@ def poll_newsgroup(mlist, conn, first, last, glock): inq.enqueue(msg, listname = mlist.internal_name(), fromusenet = 1) - syslog('fromusenet', - 'posted to list %s: %7d' % (listname, num)) + log.info('posted to list %s: %7d', listname, num) except nntplib.NNTPError, e: - syslog('fromusenet', - 'NNTP error for list %s: %7d' % (listname, num)) - syslog('fromusenet', str(e)) + log.exception('NNTP error for list %s: %7d', listname, num) except _ContinueLoop: continue # Even if we don't post the message because it was seen on the @@ -208,7 +197,7 @@ def process_lists(glock): conn, first, last = open_newsgroup(mlist) except (socket.error, nntplib.NNTPError): break - syslog('fromusenet', '%s: [%d..%d]' % (listname, first, last)) + log.info('%s: [%d..%d]', listname, first, last) try: try: if watermark is None: @@ -217,8 +206,7 @@ def process_lists(glock): # newsgroup. We essentially do a mass catch-up, otherwise # we'd flood the mailing list. mlist.usenet_watermark = last - syslog('fromusenet', '%s caught up to article %d' % - (listname, last)) + log.info('%s caught up to article %d', listname, last) else: # The list has been polled previously, so now we simply # grab all the messages on the newsgroup that have not @@ -229,25 +217,22 @@ def process_lists(glock): # has run. Not much we can do about that. start = max(watermark+1, first) if start > last: - syslog('fromusenet', 'nothing new for list %s' % - listname) + log.info('nothing new for list %s', listname) else: mlist.Lock(timeout=mm_cfg.LIST_LOCK_TIMEOUT) - syslog('fromusenet', 'gating %s articles [%d..%d]' % - (listname, start, last)) + log.info('gating %s articles [%d..%d]', + listname, start, last) # Use last+1 because poll_newsgroup() employes a for # loop over range, and this will not include the last # element in the list. poll_newsgroup(mlist, conn, start, last+1, glock) except LockFile.TimeOutError: - syslog('fromusenet', 'Could not acquire list lock: %s' % - listname) + log.error('Could not acquire list lock: %s', listname) finally: if mlist.Locked(): mlist.Save() mlist.Unlock() - syslog('fromusenet', '%s watermark: %d' % - (listname, mlist.usenet_watermark)) + log.info('%s watermark: %d', listname, mlist.usenet_watermark) @@ -258,13 +243,13 @@ def main(): try: lock.lock(timeout=0.5) except LockFile.TimeOutError: - syslog('fromusenet', 'Could not acquire gate_news lock') + log.error('Could not acquire gate_news lock') return try: process_lists(lock) finally: clearcache() - lock.unlock(unconditionally=1) + lock.unlock(unconditionally=True) |
