[Spambayes-checkins] spambayes/spambayes postfixproxy.py,1.2,1.3

Skip Montanaro montanaro at users.sourceforge.net
Sat Jun 26 17:07:39 EDT 2004


Update of /cvsroot/spambayes/spambayes/spambayes
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1612

Modified Files:
	postfixproxy.py 
Log Message:
Correct the import of smtpd.  It's probably already imported as __main__.
We don't want to import it as smtpd in that case because the main program
setup may set the DEBUGSTREAM module global.


Index: postfixproxy.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/postfixproxy.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** postfixproxy.py	26 Jun 2004 19:12:31 -0000	1.2
--- postfixproxy.py	26 Jun 2004 21:07:37 -0000	1.3
***************
*** 8,12 ****
  
  import os
! import smtpd
  import email.Parser
  from spambayes import Options, hammie, storage
--- 8,20 ----
  
  import os
! # This module is generally going to be imported from smtpd which will be run
! # as the main program and thus be named __main__.  Importing smtpd directly
! # will override any global object definitions.  In particular, the
! # DEBUGSTREAM setting might get hosed.
! import __main__ as smtpd
! if not hasattr(smtpd, "PureProxy"):
!     import smtpd
! 
! import time
  import email.Parser
  from spambayes import Options, hammie, storage
***************
*** 60,63 ****
--- 68,72 ----
  
      def process_message(self, peer, mailfrom, rcpttos, data):
+         t1 = time.time()
          try:
              msg = email.Parser.Parser().parsestr(data)
***************
*** 65,76 ****
              pass
          else:
              msg.add_header("X-Peer", peer[0])
              prob, data = self.h.score_and_filter(msg)
!             if prob >= self.spam_cutoff:
!                 self.push('503 Error: probable spam')
!                 self.log_message(data)
!                 return
  
!         refused = self._deliver(mailfrom, rcpttos, data)
!         # TBD: what to do with refused addresses?
!         print >> smtpd.DEBUGSTREAM, 'we got some refusals:', refused
--- 74,93 ----
              pass
          else:
+             t2 = time.time()
              msg.add_header("X-Peer", peer[0])
              prob, data = self.h.score_and_filter(msg)
!             t3 = time.time()
!             try:
!                 if prob >= self.spam_cutoff:
!                     self.log_message(data)
!                     print >> smtpd.DEBUGSTREAM, 'probable spam: %.2f' % prob
!                     return '503 Error: probable spam'
  
!                 refused = self._deliver(mailfrom, rcpttos, data)
!                 t4 = time.time()
!                 # TBD: what to do with refused addresses?
!                 print >> smtpd.DEBUGSTREAM, 'we got some refusals:', refused
!                 print >> smtpd.DEBUGSTREAM, 'deliver time:', t4-t3
!             finally:
!                 print >> smtpd.DEBUGSTREAM, 'parse time:', t2-t1
!                 print >> smtpd.DEBUGSTREAM, 'score time:', t3-t2




More information about the Spambayes-checkins mailing list