[Spambayes-checkins] spambayes imapfilter.py, 1.51, 1.52 smtpproxy.py, 1.14, 1.15

Tony Meyer anadelonbrin at users.sourceforge.net
Mon Sep 1 19:03:19 EDT 2003


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

Modified Files:
	imapfilter.py smtpproxy.py 
Log Message:
Clarify a print statement in smtpproxy.

imapfilter: correct options names.  correct some comments.  change some error
checking to be more certain that we will raise the error and not imaplib if something
goes wrong.  address [ 788845 ] imapfilter training fails, hopefully fixing it.

Index: imapfilter.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/imapfilter.py,v
retrieving revision 1.51
retrieving revision 1.52
diff -C2 -d -r1.51 -r1.52
*** imapfilter.py	13 Aug 2003 06:36:46 -0000	1.51
--- imapfilter.py	2 Sep 2003 01:03:16 -0000	1.52
***************
*** 60,66 ****
        much nicer.
      o IMAP over SSL is untested.
!     o Develop a test script, like testtools/pop3proxytest.py that runs
!       through some tests (perhaps with a *real* imap server, rather than
!       a dummy one).  This would make it easier to carry out the tests
        against each server whenever a change is made.
      o IMAP supports authentication via other methods than the plain-text
--- 60,66 ----
        much nicer.
      o IMAP over SSL is untested.
!     o Develop a test script, like spambayes/test/test_pop3proxy.py that
!       runs through some tests (perhaps with a *real* imap server, rather
!       than a dummy one).  This would make it easier to carry out the tests
        against each server whenever a change is made.
      o IMAP supports authentication via other methods than the plain-text
***************
*** 311,315 ****
          if self.got_substance:
              return
!         if self.uid is None or self.id is None:
              print "Cannot get substance of message without an id and an UID"
              return
--- 311,315 ----
          if self.got_substance:
              return
!         if not self.uid or not self.id:
              print "Cannot get substance of message without an id and an UID"
              return
***************
*** 318,321 ****
--- 318,322 ----
          # the status of the message.  Unfortunately, it appears that not
          # all IMAP servers support this, even though it is in RFC1730
+         # Actually, it's not: we should be using BODY.PEEK
          try:
              response = imap.uid("FETCH", self.uid, self.rfc822_command)
***************
*** 340,345 ****
          self.epilogue = new_msg.epilogue
          self._default_type = new_msg._default_type
!         if not self.has_key(options["pop3proxy", "mailid_header_name"]):
!             self[options["pop3proxy", "mailid_header_name"]] = self.id
          self.got_substance = True
          if options["globals", "verbose"]:
--- 341,346 ----
          self.epilogue = new_msg.epilogue
          self._default_type = new_msg._default_type
!         if not self.has_key(options["Headers", "mailid_header_name"]):
!             self[options["Headers", "mailid_header_name"]] = self.id
          self.got_substance = True
          if options["globals", "verbose"]:
***************
*** 360,364 ****
              raise RuntimeError, """Can't save a message that doesn't
              have a folder."""
!         if self.id is None:
              raise RuntimeError, """Can't save a message that doesn't have
              an id."""
--- 361,365 ----
              raise RuntimeError, """Can't save a message that doesn't
              have a folder."""
!         if not self.id:
              raise RuntimeError, """Can't save a message that doesn't have
              an id."""
***************
*** 403,407 ****
          imap.SelectFolder(self.folder.name)
          response = imap.uid("SEARCH", "(UNDELETED HEADER " + \
!                             options["pop3proxy", "mailid_header_name"] + \
                              " " + self.id + ")")
          self._check(response, 'search')
--- 404,408 ----
          imap.SelectFolder(self.folder.name)
          response = imap.uid("SEARCH", "(UNDELETED HEADER " + \
!                             options["Headers", "mailid_header_name"] + \
                              " " + self.id + ")")
          self._check(response, 'search')
***************
*** 416,419 ****
--- 417,430 ----
                  ids = new_id.split(' ')
                  new_id = ids[-1]
+             # Ok, now we're in trouble if we still haven't found it.
+             # We make a huge assumption that the new message is the one
+             # with the highest UID (they are sequential, so this will be
+             # ok as long as another message hasn't also arrived)
+             if new_id == "":
+                 response = imap.uid("SEARCH", "ALL")
+                 new_id = response[1][0]
+                 if new_id.find(' ') > -1:
+                     ids = new_id.split(' ')
+                     new_id = ids[-1]
          self.uid = new_id
  
***************
*** 481,485 ****
          msg.setFolder(self)
          msg.uid = key
!         r = re.compile(re.escape(options["pop3proxy",
                                           "mailid_header_name"]) + \
                         "\:\s*(\d+(\-\d)?)")
--- 492,496 ----
          msg.setFolder(self)
          msg.uid = key
!         r = re.compile(re.escape(options["Headers",
                                           "mailid_header_name"]) + \
                         "\:\s*(\d+(\-\d)?)")
***************
*** 648,653 ****
          sys.exit()
  
!     bdbname = options["pop3proxy", "persistent_storage_file"]
!     useDBM = options["pop3proxy", "persistent_use_database"]
      doTrain = False
      doClassify = False
--- 659,664 ----
          sys.exit()
  
!     bdbname = options["Storage", "persistent_storage_file"]
!     useDBM = options["Storage", "persistent_use_database"]
      doTrain = False
      doClassify = False

Index: smtpproxy.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/smtpproxy.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** smtpproxy.py	1 Sep 2003 10:33:48 -0000	1.14
--- smtpproxy.py	2 Sep 2003 01:03:17 -0000	1.15
***************
*** 453,457 ****
              print "Could not find message (%s); perhaps it was " + \
                    "deleted from the POP3Proxy cache or the IMAP " + \
!                   "server." % (id, )
  
      def train_message_in_pop3proxy_cache(self, id, isSpam):
--- 453,457 ----
              print "Could not find message (%s); perhaps it was " + \
                    "deleted from the POP3Proxy cache or the IMAP " + \
!                   "server.  This means that no training was done." % (id, )
  
      def train_message_in_pop3proxy_cache(self, id, isSpam):





More information about the Spambayes-checkins mailing list