[Spambayes-checkins] spambayes/Outlook2000 addin.py, 1.96, 1.97 filter.py, 1.30, 1.31 msgstore.py, 1.64, 1.65

Mark Hammond mhammond at users.sourceforge.net
Sun Aug 24 19:33:13 EDT 2003


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

Modified Files:
	addin.py filter.py msgstore.py 
Log Message:
Fix "[ 788495 ] Filter fails when folder full", and also report *all* errors
performing a move or copy (but only report it once per session).


Index: addin.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/addin.py,v
retrieving revision 1.96
retrieving revision 1.97
diff -C2 -d -r1.96 -r1.97
*** addin.py	24 Aug 2003 23:51:32 -0000	1.96
--- addin.py	25 Aug 2003 01:33:11 -0000	1.97
***************
*** 638,642 ****
                  print "*** Failed to set the message state to '%s' for message '%s'" % (new_msg_state, subject)
              # Now move it.
!             msgstore_message.MoveTo(spam_folder)
              # Note the move will possibly also trigger a re-train
              # but we are smart enough to know we have already done it.
--- 638,642 ----
                  print "*** Failed to set the message state to '%s' for message '%s'" % (new_msg_state, subject)
              # Now move it.
!             msgstore_message.MoveToReportingError(self.manager, spam_folder)
              # Note the move will possibly also trigger a re-train
              # but we are smart enough to know we have already done it.
***************
*** 693,697 ****
                  print "*** Failed to set the message state to '%s' for message '%s'" % (new_msg_state, subject)
              # Now move it.
!             msgstore_message.MoveTo(restore_folder)
              # Note the move will possibly also trigger a re-train
              # but we are smart enough to know we have already done it.
--- 693,697 ----
                  print "*** Failed to set the message state to '%s' for message '%s'" % (new_msg_state, subject)
              # Now move it.
!             msgstore_message.MoveToReportingError(self.manager, restore_folder)
              # Note the move will possibly also trigger a re-train
              # but we are smart enough to know we have already done it.
***************
*** 1144,1147 ****
--- 1144,1153 ----
                      print "Error processing missed messages!"
                      traceback.print_exc()
+             else:
+                 # We should include this fact in the log, as I suspect a
+                 # a number of "it doesn't work" bugs are simply related to not
+                 # being enabled.  The new Wizard should help, but things can
+                 # still screw up.
+                 self.manager.LogDebug(0, "*** SpamBayes is NOT enabled, so will not filter incoming mail. ***")
          except:
              print "Error connecting to Outlook!"

Index: filter.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/filter.py,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** filter.py	24 Aug 2003 03:05:15 -0000	1.30
--- filter.py	25 Aug 2003 01:33:11 -0000	1.31
***************
*** 73,77 ****
                            "message - this message was not copied"
                  else:
!                     msg.CopyTo(dest_folder)
              elif action.startswith("mo"): # Moved
                  dest_folder = mgr.message_store.GetFolder(folder_id)
--- 73,77 ----
                            "message - this message was not copied"
                  else:
!                     msg.CopyToReportingError(mgr, dest_folder)
              elif action.startswith("mo"): # Moved
                  dest_folder = mgr.message_store.GetFolder(folder_id)
***************
*** 80,84 ****
                            "message - this message was not moved"
                  else:
!                     msg.MoveTo(dest_folder)
              else:
                  raise RuntimeError, "Eeek - bad action '%r'" % (action,)
--- 80,84 ----
                            "message - this message was not moved"
                  else:
!                     msg.MoveToReportingError(mgr, dest_folder)
              else:
                  raise RuntimeError, "Eeek - bad action '%r'" % (action,)
***************
*** 86,93 ****
          return disposition
      except:
-         # Have seen MAPI_E_TABLE_TOO_BIG errors reported here when doing the
-         # move, but in what is probably a semi-corrupt pst.
-         # However, this *is* a legitimate error to get if the target folder
-         # has > 16,383 entries.
          print "Failed filtering message!", msg
          import traceback
--- 86,89 ----

Index: msgstore.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/msgstore.py,v
retrieving revision 1.64
retrieving revision 1.65
diff -C2 -d -r1.64 -r1.65
*** msgstore.py	24 Aug 2003 03:00:49 -0000	1.64
--- msgstore.py	25 Aug 2003 01:33:11 -0000	1.65
***************
*** 126,129 ****
--- 126,145 ----
      return "Exception 0x%x (%s): %s" % (hr, err_string, msg)
  
+ def ReportMAPIError(manager, what, exc_type, exc_val):
+     hr, exc_msg, exc, arg_err = exc_val
+     if hr == mapi.MAPI_E_TABLE_TOO_BIG:
+         err_msg = what + " failed as one of your\r\n" \
+                     "Outlook folders is full.  Futher operations are\r\n" \
+                     "likely to fail until you clean up this folder.\r\n\r\n" \
+                     "This message will not be reported again until SpamBayes\r\n"\
+                     "is restarted."
+     else:
+         err_msg = what + " failed due to an unexpected Outlook error.\r\n" \
+                   + GetCOMExceptionString(exc_val) + "\r\n\r\n" \
+                   "It is recommended you restart Outlook at the earliest opportunity\r\n\r\n" \
+                   "This message will not be reported again until SpamBayes\r\n"\
+                   "is restarted."
+     manager.ReportErrorOnce(err_msg)
+ 
  class MAPIMsgStore(MsgStore):
      def __init__(self, outlook = None):
***************
*** 939,947 ****
          eid = self.id[1]
          source_folder.CopyMessages((eid,),
!                                    None,
!                                    dest_folder,
!                                    0,
!                                    None,
!                                    flags)
          # At this stage, I think we have lost meaningful ID etc values
          # Set everything to None to make it clearer what is wrong should
--- 955,963 ----
          eid = self.id[1]
          source_folder.CopyMessages((eid,),
!                                     None,
!                                     dest_folder,
!                                     0,
!                                     None,
!                                     flags)
          # At this stage, I think we have lost meaningful ID etc values
          # Set everything to None to make it clearer what is wrong should
***************
*** 956,959 ****
--- 972,992 ----
      def CopyTo(self, folder):
          self._DoCopyMove(folder, False)
+ 
+     # Functions to perform operations, but report the error (ONCE!) to the
+     # user.  Any errors are re-raised so the caller can degrade gracefully if
+     # necessary.
+     def MoveToReportingError(self, manager, folder):
+         try:
+             self.MoveTo(folder)
+         except pythoncom.com_error, details:
+             ReportMAPIError(manager, "Moving a message", pythoncom.com_error, details)
+             raise
+     def CopyToReportingError(self, manager, folder):
+         try:
+             self.MoveTo(folder)
+         except pythoncom.com_error, details:
+             ReportMAPIError(manager, "Copying a message", pythoncom.com_error, details)
+             raise
+ 
      def GetFolder(self):
          # return a folder object with the parent, or None





More information about the Spambayes-checkins mailing list