[Spambayes-checkins] spambayes pop3proxy.py,1.89,1.90

Tony Meyer anadelonbrin at users.sourceforge.net
Sun Aug 17 22:52:56 EDT 2003


Update of /cvsroot/spambayes/spambayes
In directory sc8-pr-cvs1:/tmp/cvs-serv19275

Modified Files:
	pop3proxy.py 
Log Message:
Provide a simpler interface to pop3proxy, primarily for the windows service,
but should also be useful for any other users.

Adjust pop3proxy_service to use these, which also means that it will
kick of smtpproxy (if applicable), unlike previously.

Index: pop3proxy.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/pop3proxy.py,v
retrieving revision 1.89
retrieving revision 1.90
diff -C2 -d -r1.89 -r1.90
*** pop3proxy.py	28 Jul 2003 20:13:55 -0000	1.89
--- pop3proxy.py	18 Aug 2003 04:52:53 -0000	1.90
***************
*** 94,97 ****
--- 94,98 ----
  from email.Header import Header
  
+ import smtpproxy
  import spambayes.message
  from spambayes import Dibbler
***************
*** 607,614 ****
              options["pop3proxy", "persistent_storage_file"] = \
                          '_pop3proxy_test.pickle'   # This is never saved.
!         filename = options["pop3proxy", "persistent_storage_file"]
          filename = os.path.expanduser(filename)
          if self.useDB:
!             self.bayes = storage.DBDictClassifier(filename)
          else:
              self.bayes = storage.PickledClassifier(filename)
--- 608,626 ----
              options["pop3proxy", "persistent_storage_file"] = \
                          '_pop3proxy_test.pickle'   # This is never saved.
!         filename = options["Storage", "persistent_storage_file"]
          filename = os.path.expanduser(filename)
          if self.useDB:
!             if '::' in filename:
!                 sql_types = {"pgsql" : storage.PGClassifier,
!                              "mysql" : storage.mySQLClassifier,
!                              }
!                 sql_type, rest = filename.split('::', 1)
!                 if sql_types.has_key(sql_type.lower()):
!                     self.bayes = sql_types[sql_type.lower()](filename)
!                 else:
!                     # yikes! raise some sort of NoSuchClassifierError
!                     pass
!             else:
!                 self.bayes = storage.DBDictClassifier(filename)
          else:
              self.bayes = storage.PickledClassifier(filename)
***************
*** 728,731 ****
--- 740,764 ----
      Dibbler.run(launchBrowser=launchUI)
  
+ def prepare(state):
+     # Do whatever we've been asked to do...
+     state.createWorkers()
+ 
+     # Launch any SMTP proxies.  Note that if the user hasn't specified any
+     # SMTP proxy information in their configuration, then nothing will
+     # happen.
+     servers, proxyPorts = smtpproxy.LoadServerInfo()
+     smtpproxy.CreateProxies(servers, proxyPorts, state)
+ 
+     # setup info for the web interface
+     state.buildServerStrings()
+ 
+ def start(state):
+     # kick everything off    
+     main(state.servers, state.proxyPorts, state.uiPort, state.launchUI)
+ 
+ def stop(state):
+     state.bayes.store()
+     # should we be calling socket.shutdown(2) and close() for each
+     # BayesProxy object?
  
  # ===================================================================
***************
*** 767,781 ****
      print "and engine %s.\n" % (get_version_string(),)
  
!     # Do whatever we've been asked to do...
!     state.createWorkers()
! 
!     # Launch any SMTP proxies.  This was once an option, but
!     # is now always carried out - if the user hasn't specified any
!     # SMTP proxy information in their configuration, then nothing
!     # will happen anyway, and this is much clearer for documentation.
!     from smtpproxy import LoadServerInfo, CreateProxies
!     servers, proxyPorts = LoadServerInfo()
!     CreateProxies(servers, proxyPorts, state)
!     LoadServerInfo()
  
      if 0 <= len(args) <= 2:
--- 800,804 ----
      print "and engine %s.\n" % (get_version_string(),)
  
!     prepare(state=state)
  
      if 0 <= len(args) <= 2:
***************
*** 786,791 ****
              state.servers = [(args[0], int(args[1]))]
  
!         state.buildServerStrings()
!         main(state.servers, state.proxyPorts, state.uiPort, state.launchUI)
  
      else:
--- 809,813 ----
              state.servers = [(args[0], int(args[1]))]
  
!         start(state=state)
  
      else:





More information about the Spambayes-checkins mailing list