[Spambayes-checkins] spambayes/spambayes ProxyUI.py, 1.62, 1.63 UserInterface.py, 1.59, 1.60

Tony Meyer anadelonbrin at users.sourceforge.net
Mon Nov 28 03:10:22 CET 2005


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

Modified Files:
	ProxyUI.py UserInterface.py 
Log Message:
If the user changes the database type in the configuration page, automatically convert the database for them, rather than crashing.

Index: ProxyUI.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/ProxyUI.py,v
retrieving revision 1.62
retrieving revision 1.63
diff -C2 -d -r1.62 -r1.63
*** ProxyUI.py	14 Apr 2005 06:18:16 -0000	1.62
--- ProxyUI.py	28 Nov 2005 02:10:14 -0000	1.63
***************
*** 7,11 ****
  
  This module implements a browser based Spambayes user interface for the
! POP3 proxy and SMTP proxy.  Users may use it to interface with the
  proxies.
  
--- 7,11 ----
  
  This module implements a browser based Spambayes user interface for the
! POP3, IMAP4 SMTP proxies.  Users may use it to interface with the
  proxies.
  
***************
*** 88,91 ****
--- 88,94 ----
      ('pop3proxy',           'remote_servers'),
      ('pop3proxy',           'listen_ports'),
+ #    ('IMAP4 Proxy Options',  None),
+ #    ('imap4proxy',          'remote_servers'),
+ #    ('imap4proxy',          'listen_ports'),
      ('SMTP Proxy Options',  None),
      ('smtpproxy',           'remote_servers'),
***************
*** 169,174 ****
                                               proxy_state.stats)
          state = proxy_state
          self.state_recreator = state_recreator # ugly
!         self.app_for_version = "SpamBayes POP3 Proxy"
          self.previous_sort = None
          if not proxy_state.can_stop:
--- 172,178 ----
                                               proxy_state.stats)
          state = proxy_state
+         self.state = proxy_state
          self.state_recreator = state_recreator # ugly
!         self.app_for_version = "SpamBayes Proxy"
          self.previous_sort = None
          if not proxy_state.can_stop:
***************
*** 228,232 ****
          of the given day, the end timestamp of the given day, and the
          formatted date of the given day."""
-         # This probably works on Summertime-shift days; time will tell.  8-)
          this = time.localtime(timestamp)
          start = (this[0], this[1], this[2], 0, 0, 0, this[6], this[7], this[8])
--- 232,235 ----
***************
*** 777,780 ****
--- 780,784 ----
          state = self.state_recreator()
          self.classifier = state.bayes
+         self.state = state
  
      def verifyInput(self, parms, pmap):

Index: UserInterface.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/UserInterface.py,v
retrieving revision 1.59
retrieving revision 1.60
diff -C2 -d -r1.59 -r1.60
*** UserInterface.py	15 Nov 2005 00:13:54 -0000	1.59
--- UserInterface.py	28 Nov 2005 02:10:14 -0000	1.60
***************
*** 835,838 ****
--- 835,841 ----
              return
  
+         old_database_type = options["Storage", "persistent_use_database"]
+         old_name = options["Storage", "persistent_storage_file"]
+ 
          for name, value in parms.items():
              sect, opt = name.split('_', 1)
***************
*** 847,850 ****
--- 850,885 ----
  
          options.update_file(optionsPathname)
+ 
+         # If the database type changed, then convert it for them.
+         if options["Storage", "persistent_use_database"] != \
+            old_database_type and os.path.exists(old_name):
+             new_name = options["Storage", "persistent_storage_file"]
+             new_type = options["Storage", "persistent_use_database"]
+             self.state.close()
+             try:
+                 os.remove(new_name + ".tmp")
+             except OSError:
+                 pass
+             storage.convert(old_name, old_database_type,
+                             new_name + ".tmp", new_type)
+             if os.path.exists(new_name):
+                 try:
+                     os.remove(new_name + ".old")
+                 except OSError:
+                     pass
+                 os.rename(new_name, new_name + ".old")
+             os.rename(new_name + ".tmp", new_name)
+             # Messageinfo db is not converted.
+             if os.path.exists(options["Storage",
+                                       "messageinfo_storage_file"]):
+                 try:
+                     os.remove(options["Storage",
+                                       "messageinfo_storage_file"] + ".old")
+                 except OSError:
+                     pass
+                 os.rename(options["Storage", "messageinfo_storage_file"],
+                           options["Storage",
+                                   "messageinfo_storage_file"] + ".old")
+             
          self.reReadOptions()
  



More information about the Spambayes-checkins mailing list