[Spambayes-checkins] spambayes/Outlook2000 filter.py, 1.25, 1.26 msgstore.py, 1.47, 1.48

Mark Hammond mhammond at users.sourceforge.net
Wed Jul 9 01:51:45 EDT 2003


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

Modified Files:
	filter.py msgstore.py 
Log Message:
Use the passed field name rather than hardcoded "Spam".

msgstore: Don't catch exceptions doing a save - let the caller do that.
filter: Catch the above mentioned exceptions :)  This puts the dodgy
IMAP and hotmail handling in one place and fixes:
765042: IMAP mail fails to filter


Index: filter.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/filter.py,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** filter.py	18 Jun 2003 01:59:02 -0000	1.25
--- filter.py	9 Jul 2003 07:51:42 -0000	1.26
***************
*** 10,13 ****
--- 10,14 ----
      True, False = 1, 0
  
+ import pythoncom # for the exceptions.
  
  def filter_message(msg, mgr, all_actions=True):
***************
*** 41,53 ****
                  msg.RememberMessageCurrentFolder()
              msg.Save()
!         except:
!             # XXX - unfortunately, for the case I added this code, a failing
!             # Save *did* imply a failing Move :(
!             # I also heard a rumour hotmail works if we do 2 saves.
!             # This should be revisited.
!             print "Failed to save the Spam score for message ", msg
!             import traceback
!             traceback.print_exc()
!             print "Still (possibly) atempting to move this message though..."
  
          if all_actions and attr_prefix is not None:
--- 42,60 ----
                  msg.RememberMessageCurrentFolder()
              msg.Save()
!         except pythoncom.com_error, (hr, msg, exc, arg_err):
!             # This seems to happen for IMAP mails (0x800cccd3)
!             # and also for hotmail messages (0x8004dff7)
!             known_failure_codes = -2146644781, -2147164169
!             # I also heard a rumour hotmail works if we do 2 saves
!             if hr not in known_failure_codes:
!                 print "Unexpected MAPI error saving the spam score for", msg
!                 print hr, msg, exc
!             else:
!                 # So we can see if it still happens :)
!                 mgr.LogDebug(1, "Note: known (but still not understood) " \
!                                 "error 0x%x saving the spam score." % hr)
!             # No need for a traceback in this case.
!             # Clear dirty flag anyway
!             msg.dirty = False
  
          if all_actions and attr_prefix is not None:

Index: msgstore.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/msgstore.py,v
retrieving revision 1.47
retrieving revision 1.48
diff -C2 -d -r1.47 -r1.48
*** msgstore.py	17 Jun 2003 02:04:11 -0000	1.47
--- msgstore.py	9 Jul 2003 07:51:42 -0000	1.48
***************
*** 427,431 ****
          table = folder.GetContentsTable(0)
          # Resolve the field name
!         resolve_props = ( (mapi.PS_PUBLIC_STRINGS, "Spam"), )
          resolve_ids = folder.GetIDsFromNames(resolve_props, 0)
          field_id = PROP_TAG( PT_DOUBLE, PROP_ID(resolve_ids[0]))
--- 427,431 ----
          table = folder.GetContentsTable(0)
          # Resolve the field name
!         resolve_props = ( (mapi.PS_PUBLIC_STRINGS, scoreFieldName), )
          resolve_ids = folder.GetIDsFromNames(resolve_props, 0)
          field_id = PROP_TAG( PT_DOUBLE, PROP_ID(resolve_ids[0]))
***************
*** 793,803 ****
      def Save(self):
          assert self.dirty, "asking me to save a clean message!"
!         try:
!             self.mapi_object.SaveChanges(mapi.KEEP_OPEN_READWRITE | USE_DEFERRED_ERRORS)
!         except pythoncom.com_error, details:
!             # hotmail gives this error - not sure what code, but
!             # we don't want to mask other errors.
!             if details[0] != -2147164169: # 0x8004dff7
!                 raise
          self.dirty = False
  
--- 793,802 ----
      def Save(self):
          assert self.dirty, "asking me to save a clean message!"
!         # There are some known exceptions that can be raised by IMAP and hotmail
!         # For now, we just let the caller handle all errors, and manually
!         # reset the dirty flag.  Only current caller is filter.py
!         # There are also some issues with the "unread flag" that fiddling this
!         # save code may fix.
!         self.mapi_object.SaveChanges(mapi.KEEP_OPEN_READWRITE | USE_DEFERRED_ERRORS)
          self.dirty = False
  





More information about the Spambayes-checkins mailing list