[Zope-Checkins] CVS: Zope2 - testCatalog.py:1.1.4.8

Andreas Jung andreas@dhcp165.digicool.com
Tue, 13 Mar 2001 17:04:23 -0500


Update of /mnt/cvs-repository/Zope2/lib/python/Products/ZCatalog/tests
In directory yetix:/work/Zope2/Catalog-BTrees-Integration/lib/python/Products/ZCatalog/tests

Modified Files:
      Tag: Catalog-BTrees-Integration
	testCatalog.py 
Log Message:
added try/except while reading and parsing the mbox file



--- Updated File testCatalog.py in package Zope2 --
--- testCatalog.py	2001/03/13 16:51:07	1.1.4.7
+++ testCatalog.py	2001/03/13 22:04:20	1.1.4.8
@@ -7,6 +7,9 @@
     Andreas Jung, andreas@digicool.com
     
     $Log$
+    Revision 1.1.4.8  2001/03/13 22:04:20  andreas
+    added try/except while reading and parsing the mbox file
+
     Revision 1.1.4.7  2001/03/13 16:51:07  andreas
     code cleanup
 
@@ -162,14 +165,20 @@
 
         msg = mb.next()
         while msg and self.num_files<self.maxfiles:
-            self.catMessage(msg)
+
+            try:
+                self.catMessage(msg)
+            except: 
+                msg = mb.next()
+                continue
+
             self.msg_ids.append(msg.dict["message-id"])
 
             msg = mb.next()
             self.num_files = self.num_files + 1
             if self.num_files % 100==0: print self.num_files
 
-            sub = string.split(msg.dict["subject"])
+            sub = string.split(msg.dict.get("subject",""))
             for s in sub: 
                 if not s in self.keywords: self.keywords.append(s)
             
@@ -288,7 +297,6 @@
         
         self.zodb 	 	= testZODB("data/work/Data.fs",open=0)
         self.threads    = {} 
-        self.conflicts  = {}
 
         kw = keywords.Keywords()
         kw.reload()
@@ -457,7 +465,7 @@
     def funcUpdates(self,*args,**kw):
         """ benchmark concurrent catalog/uncatalog operations """
 
-        conflicts = 0
+        uncat_conflicts = cat_conflicts = 0
         cat,msg_ids = self.get_catalog()
 
         msgs = self.setupUpdatesMethod(kw["numUpdates"])
@@ -475,30 +483,31 @@
             mid = keys[r]
             obj = msgs[mid]
 
-
             try:
                 cat.uncatalogObject(mid)
 
                 if kw.get("commit",1)==1:
                     get_transaction().commit()            
                     time.sleep(0.1)
+            except ZODB.POSException.ConflictError:
+                uncat_conflicts = uncat_conflicts + 1
 
+            try:
                 cat.catalogObject(obj,mid)
+
                 if kw.get("commit",1)==1:
                     get_transaction().commit()            
                     time.sleep(0.1)
 
             except ZODB.POSException.ConflictError:
-                print sys.exc_type,sys.exc_value
-                conflicts = conflicts + 1
+                cat_conflicts = cat_conflicts + 1
 
         try:
             get_transaction().commit()            
-        except:
-            conflicts = conflicts + 1
+        except: pass
 
 
-        self.th_teardown(env,conflicts=conflicts)
+        self.th_teardown(env,cat_conflicts=cat_conflicts,uncat_conflicts=uncat_conflicts)
 
 
     def setupUpdatesMethod(self,numUpdates):