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

Modified Files:
        sb_imapfilter.py 
Log Message:
For each IMAP server, load a separate configuration file into the existing one 
for
 the duration of the classify/train, if it exists.

Index: sb_imapfilter.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/scripts/sb_imapfilter.py,v
retrieving revision 1.53
retrieving revision 1.54
diff -C2 -d -r1.53 -r1.54
*** sb_imapfilter.py    14 Feb 2005 06:08:10 -0000      1.53
--- sb_imapfilter.py    16 Mar 2005 03:35:02 -0000      1.54
***************
*** 95,99 ****
  from spambayes import Stats
  from spambayes import message
! from spambayes.Options import options, get_pathname_option
  from spambayes import tokenizer, storage, message, Dibbler
  from spambayes.UserInterface import UserInterfaceServer
--- 95,99 ----
  from spambayes import Stats
  from spambayes import message
! from spambayes.Options import options, get_pathname_option, optionsPathname
  from spambayes import tokenizer, storage, message, Dibbler
  from spambayes.UserInterface import UserInterfaceServer
***************
*** 1122,1125 ****
--- 1122,1137 ----
              imaps.append((IMAPSession(server, port, imapDebug, doExpunge),
                            username, password))
+ 
+         # In order to make working with multiple servers easier, we
+         # allow the user to have separate configuration files for each
+         # server.  These may specify different folders to watch, different
+         # spam/unsure folders, or any other options (e.g. thresholds).
+         # For each server we use the default (global) options, and load
+         # the specific options on top.  To facilitate this, we use a
+         # restore point for the options with just the default (global)
+         # options.
+         # XXX What about when we are running with -l and change options
+         # XXX via the web interface?  We need to handle that, really.
+         options.set_restore_point()
          while True:
              for imap, username, password in imaps:
***************
*** 1127,1130 ****
--- 1139,1157 ----
                      print "Account: %s:%s" % (imap.server, imap.port)
                  if imap.connected:
+                     # As above, we load a separate configuration file
+                     # for each server, if it exists.  We look for a
+                     # file in the optionsPathname directory, with the
+                     # name server.name.ini or .spambayes_server_name_rc
+                     # XXX While 1.1 is in alpha these names can be
+                     # XXX changed if desired.  Please let Tony know!
+                     basedir = os.path.dirname(optionsPathname)
+                     fn1 = os.path.join(basedir, imap.server + ".ini")
+                     fn2 = os.path.join(basedir,
+                                        imap.server.replace(".", "_") + \
+                                        "_rc")
+                     for fn in (fn1, fn2):
+                         if os.path.exists(fn):
+                             options.merge_file(fn)
+                             
                      imap.login(username, password)
                      imap_filter.imap_server = imap
***************
*** 1140,1143 ****
--- 1167,1171 ----
  
                      imap.logout()
+                     options.revert_to_restore_point()
                  else:
                      # Failed to connect.  This may be a temporary problem,
***************
*** 1145,1148 ****
--- 1173,1177 ----
                      # running once we will end, otherwise we'll try again
                      # in sleepTime seconds.
+                     # XXX Maybe we should log this error message?
                      pass
  

_______________________________________________
Spambayes-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/spambayes-checkins

Reply via email to