Update of /cvsroot/mailman/mailman/Mailman/Bouncers
In directory usw-pr-cvs1:/tmp/cvs-serv9874/Mailman/Bouncers

Modified Files:
        BouncerAPI.py 
Log Message:
ScanMessage(): This is an internal API change to make life much easier
for the BounceRunner.  Instead of actually registering the bounces
here, it simply returns the list of addresses that have matched.  It
returns an empty list if none of the bounce detectors found any
addresses.

I'm also ripping out the test code.  The unit test suite is more
appropriate.


Index: BouncerAPI.py
===================================================================
RCS file: /cvsroot/mailman/mailman/Mailman/Bouncers/BouncerAPI.py,v
retrieving revision 2.11
retrieving revision 2.12
diff -C2 -d -r2.11 -r2.12
*** BouncerAPI.py       16 Mar 2002 06:57:36 -0000      2.11
--- BouncerAPI.py       26 Mar 2002 22:12:28 -0000      2.12
***************
*** 24,34 ****
  
  import sys
- import traceback
- from types import ListType
- from cStringIO import StringIO
- 
- # testing kludge
- if __name__ == '__main__':
-     execfile('bin/paths.py')
  
  from Mailman.Logging.Syslog import syslog
--- 24,27 ----
***************
*** 45,49 ****
  
  # msg must be a mimetools.Message
! def ScanMessages(mlist, msg, testing=0):
      pipeline = ['DSN',
                  'Qmail',
--- 38,42 ----
  
  # msg must be a mimetools.Message
! def ScanMessages(mlist, msg):
      pipeline = ['DSN',
                  'Qmail',
***************
*** 67,119 ****
          addrs = sys.modules[modname].process(msg)
          if addrs is Stop:
!             return 1
!         if addrs:
!             for addr in addrs:
!                 if not addr:
!                     continue
!                 # we found a bounce or a list of bounce addrs
!                 if not testing:
!                     try:
!                         mlist.registerBounce(addr, msg)
!                     except Exception, e:
!                         syslog(
!                             'error',
!                             'Bouncer exception while processing module %s: %s',
!                             module, e)
!                         s = StringIO()
!                         traceback.print_exc(file=s)
!                         syslog('error', s.getvalue())
!                         return 0
!                 else:
!                     print '\t%s: detected address <%s>' % (modname, addr)
!             # we saw some bounces
!             return 1
! ##        else:
! ##            if testing:
! ##                print '\t%11s: no bounces detected' % modname
!     # no bounces detected
!     return 0
! 
! 
! 
! # for testing
! if __name__ == '__main__':
!     from Mailman import Message
!     from Mailman.i18n import _
!     import email
! 
!     def usage(code, msg=''):
!         print >> sys.stderr, _(__doc__)
!         if msg:
!             print >> sys.stderr, msg
!         sys.exit(code)
! 
!     if len(sys.argv) < 2:
!         usage(1, 'required arguments: <file> [, <file> ...]')
! 
!     for filename in sys.argv[1:]:
!         print 'scanning file', filename
!         fp = open(filename)
!         msg = email.message_from_file(fp, Message.Message)
!         fp.close()
!         ScanMessages(None, msg, testing=1)
--- 60,67 ----
          addrs = sys.modules[modname].process(msg)
          if addrs is Stop:
!             # One of the detectors recognized the bounce, but there were no
!             # addresses to extract.  Return the empty list.
!             return []
!         elif addrs:
!             return addrs
!     return []


_______________________________________________
Mailman-checkins mailing list
[EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/mailman-checkins

Reply via email to