[Spambayes-checkins] spambayes/Outlook2000 manager.py, 1.61, 1.62 addin.py, 1.64, 1.65 config.py, 1.12, 1.13

Mark Hammond mhammond at users.sourceforge.net
Thu Jun 19 17:47:42 EDT 2003


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

Modified Files:
	manager.py addin.py config.py 
Log Message:
Add a 'verbose' option to the options.  Formalize with a 
LogDebug(level, val, ...) method, and add some extra debugging
logs for toolbars.


Index: manager.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/manager.py,v
retrieving revision 1.61
retrieving revision 1.62
diff -C2 -d -r1.61 -r1.62
*** manager.py	17 Jun 2003 04:07:43 -0000	1.61
--- manager.py	19 Jun 2003 23:47:40 -0000	1.62
***************
*** 238,241 ****
--- 238,247 ----
          self.LoadBayes()
  
+     def LogDebug(self, level, *args):
+         if self.verbose >= level:
+             for arg in args[:-1]:
+                 print arg,
+             print args[-1]
+ 
      def ReportError(self, message, title = None):
          ReportError(message, title)
***************
*** 361,367 ****
              
          folder = msgstore_folder.GetOutlookItem()
!         if self.verbose > 1:
!             print "Checking folder '%s' for our field '%s'" \
!                   % (self.config.general.field_score_name,folder.Name.encode("mbcs", "replace"))
          items = folder.Items
          item = items.GetFirst()
--- 367,372 ----
              
          folder = msgstore_folder.GetOutlookItem()
!         self.LogDebug(2, "Checking folder '%s' for our field '%s'" \
!                   % (self.config.general.field_score_name,folder.Name.encode("mbcs", "replace")))
          items = folder.Items
          item = items.GetFirst()
***************
*** 390,395 ****
                             format)
                      item.Save()
!                     if self.verbose > 1:
!                         print "Created the UserProperty!"
                  except pythoncom.com_error, details:
                      print "Warning: failed to create the Outlook " \
--- 395,399 ----
                             format)
                      item.Save()
!                     self.LogDebug(2, "Created the UserProperty!")
                  except pythoncom.com_error, details:
                      print "Warning: failed to create the Outlook " \
***************
*** 431,436 ****
              bayes = self.bayes
              message_db = self.message_db
!         if self.verbose:
!             print ("Bayes database initialized with "
                     "%d spam and %d good messages" % (bayes.nspam, bayes.nham))
          if len(message_db) != bayes.nham + bayes.nspam:
--- 435,439 ----
              bayes = self.bayes
              message_db = self.message_db
!         self.LogDebug(0, "Bayes database initialized with "
                     "%d spam and %d good messages" % (bayes.nspam, bayes.nham))
          if len(message_db) != bayes.nham + bayes.nspam:
***************
*** 440,445 ****
          self.message_db = message_db
          self.bayes_dirty = False
!         if self.verbose:
!             print "Loaded databases in %gms" % ((time.clock()-start)*1000)
  
      def PrepareConfig(self):
--- 443,447 ----
          self.message_db = message_db
          self.bayes_dirty = False
!         self.LogDebug(1, "Loaded databases in %gms" % ((time.clock()-start)*1000))
  
      def PrepareConfig(self):
***************
*** 490,493 ****
--- 492,500 ----
          # Now load it up
          self._MergeConfigFile(self.config_filename)
+         # Set global verbosity from the options file.
+         self.verbose = self.config.general.verbose
+         if self.verbose:
+             self.LogDebug(self.verbose, "System verbosity set to", self.verbose)
+ 
          self.MigrateOldPickle()
  
***************
*** 499,504 ****
              f = open(pickle_filename, 'rb')
          except IOError:
!             if self.verbose:
!                 print "No old pickle file to migrate"
              return
          print "Migrating old pickle '%s'" % pickle_filename
--- 506,510 ----
              f = open(pickle_filename, 'rb')
          except IOError:
!             self.LogDebug(1, "No old pickle file to migrate")
              return
          print "Migrating old pickle '%s'" % pickle_filename
***************
*** 533,542 ****
          # migrate will fail.  We save first, so failure here means next
          # attempt should still find the pickle.
!         if self.verbose:
!             print "pickle migration doing initial configuration save"
!         self.SaveConfig()
          try:
!             if self.verbose:
!                 print "pickle migration removing '%s'" % pickle_filename
              os.remove(pickle_filename)
          except os.error:
--- 539,545 ----
          # migrate will fail.  We save first, so failure here means next
          # attempt should still find the pickle.
!         self.LogDebug(1, "pickle migration doing initial configuration save")
          try:
!             self.LogDebug(1, "pickle migration removing '%s'" % pickle_filename)
              os.remove(pickle_filename)
          except os.error:
***************
*** 587,592 ****
          self.db_manager.store_mdb(self.message_db)
          self.bayes_dirty = False
!         if self.verbose:
!             print "Saved databases in %gms" % ((time.clock()-start)*1000)
  
      def GetClassifier(self):
--- 590,594 ----
          self.db_manager.store_mdb(self.message_db)
          self.bayes_dirty = False
!         self.LogDebug(1, "Saved databases in %gms" % ((time.clock()-start)*1000))
  
      def GetClassifier(self):

Index: addin.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/addin.py,v
retrieving revision 1.64
retrieving revision 1.65
diff -C2 -d -r1.64 -r1.65
*** addin.py	18 Jun 2003 13:05:55 -0000	1.64
--- addin.py	19 Jun 2003 23:47:40 -0000	1.65
***************
*** 641,645 ****
      # The Outlook event handlers
      def OnActivate(self):
!         #print "OnActivate", self
          # See comments for OnNewExplorer below.
          # *sigh* - OnActivate seems too early too for Outlook 2000,
--- 641,645 ----
      # The Outlook event handlers
      def OnActivate(self):
!         self.manager.LogDebug(2, "OnActivate", self)
          # See comments for OnNewExplorer below.
          # *sigh* - OnActivate seems too early too for Outlook 2000,
***************
*** 651,655 ****
  
      def OnSelectionChange(self):
!         #print "OnSelChange", self
          # See comments for OnNewExplorer below.
          if not self.have_setup_ui:
--- 651,655 ----
  
      def OnSelectionChange(self):
!         self.manager.LogDebug(2, "OnSelectionChange", self)
          # See comments for OnNewExplorer below.
          if not self.have_setup_ui:
***************
*** 659,663 ****
  
      def OnClose(self):
!         #print "OnClose", self
          self.explorers_collection._DoDeadExplorer(self)
          self.explorers_collection = None
--- 659,663 ----
  
      def OnClose(self):
!         self.manager.LogDebug(2, "OnClose", self)
          self.explorers_collection._DoDeadExplorer(self)
          self.explorers_collection = None
***************
*** 665,670 ****
          self.close() # disconnect events.
  
      def OnFolderSwitch(self):
!         #print "OnFolderSwitch", self
          # Yet another worm-around for our event timing woes.  This may
          # be the first event ever seen for this explorer if, eg,
--- 665,673 ----
          self.close() # disconnect events.
  
+     def OnBeforeFolderSwitch(self, new_folder, cancel):
+         self.manager.LogDebug(2, "OnBeforeFolderSwitch", self)
+ 
      def OnFolderSwitch(self):
!         self.manager.LogDebug(2, "OnFolderSwitch", self)
          # Yet another worm-around for our event timing woes.  This may
          # be the first event ever seen for this explorer if, eg,
***************
*** 706,711 ****
              self.but_delete_as.Visible = show_delete_as
  
      def OnViewSwitch(self):
!         #print "OnViewSwitch", self
          if not self.have_setup_ui:
              self.SetupUI()
--- 709,717 ----
              self.but_delete_as.Visible = show_delete_as
  
+     def OnBeforeViewSwitch(self, new_view, cancel):
+         self.manager.LogDebug(2, "OnBeforeViewSwitch", self)
+ 
      def OnViewSwitch(self):
!         self.manager.LogDebug(2, "OnViewSwitch", self)
          if not self.have_setup_ui:
              self.SetupUI()
***************
*** 924,935 ****
--- 930,945 ----
  
  def RegisterAddin(klass):
+     # prints to help debug binary install issues.
+     print "Starting register"
      import _winreg
      key = _winreg.CreateKey(_winreg.HKEY_CURRENT_USER,
                              "Software\\Microsoft\\Office\\Outlook\\Addins")
      subkey = _winreg.CreateKey(key, klass._reg_progid_)
+     print "Setting values"
      _winreg.SetValueEx(subkey, "CommandLineSafe", 0, _winreg.REG_DWORD, 0)
      _winreg.SetValueEx(subkey, "LoadBehavior", 0, _winreg.REG_DWORD, 3)
      _winreg.SetValueEx(subkey, "Description", 0, _winreg.REG_SZ, "SpamBayes anti-spam tool")
      _winreg.SetValueEx(subkey, "FriendlyName", 0, _winreg.REG_SZ, "SpamBayes")
+     print "Registration complete."
  
  def UnregisterAddin(klass):

Index: config.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/config.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** config.py	18 Jun 2003 02:29:49 -0000	1.12
--- config.py	19 Jun 2003 23:47:40 -0000	1.13
***************
*** 27,31 ****
  from spambayes.OptionsClass import OptionsClass, Option
  from spambayes.OptionsClass import RESTORE, DO_NOT_RESTORE
! from spambayes.OptionsClass import BOOLEAN, REAL, PATH
  
  class FolderIDOption(Option):
--- 27,31 ----
  from spambayes.OptionsClass import OptionsClass, Option
  from spambayes.OptionsClass import RESTORE, DO_NOT_RESTORE
! from spambayes.OptionsClass import BOOLEAN, INTEGER, REAL, PATH
  
  class FolderIDOption(Option):
***************
*** 101,104 ****
--- 101,107 ----
             also be set.""",
             MSG_READ_STATE, RESTORE),
+     ("verbose", "Changes the verbosity of the debug output from the program", 0,
+         """""",
+         INTEGER, RESTORE),
      ),
      "Training" : (





More information about the Spambayes-checkins mailing list