[Zope-Checkins] CVS: Zope/lib/python/Products/ZCatalog/regressiontests - loadmail.py:1.7.4.1

Chris McDonough chrism@zope.com
Mon, 26 Aug 2002 02:23:08 -0400


Update of /cvs-repository/Zope/lib/python/Products/ZCatalog/regressiontests
In directory cvs.zope.org:/tmp/cvs-serv29520/lib/python/Products/ZCatalog/regressiontests

Modified Files:
      Tag: chrism-install-branch
	loadmail.py 
Log Message:
More work on my Zope2 installer branch.  The branch is fully functional
at this point, at least on Linux (try it!).  The goal is to allow
a './configure; make; make install' Zope source installation possible. 

- The 'configure' step now checks for large file support
  and will only allow configuration to continue if you
  say "yes, I want to screw myself later." ;-)

- Replaced 'zctl' with Tres' 'zopectl'.  In the process,
  refactored zopectl so that it uses a Squid-like config file.
  The config file consists of "directives", each of
  which has a particular set of possible values explained
  in the config file.  The config file provides a uniform
  front-end to the mish-mash of environment variables
  and command-line switches that you normally need to
  deal with when you configure a Zope instance.

- Created a new package in software_home named Controller
  which holds the zctl libraries and some useful scripts
  to create directives.

- Merged HEAD changes onto branch.



=== Zope/lib/python/Products/ZCatalog/regressiontests/loadmail.py 1.7 => 1.7.4.1 ===
--- Zope/lib/python/Products/ZCatalog/regressiontests/loadmail.py:1.7	Wed Aug 14 18:25:16 2002
+++ Zope/lib/python/Products/ZCatalog/regressiontests/loadmail.py	Mon Aug 26 02:22:37 2002
@@ -117,17 +117,22 @@
 
 def do(db, f, args, returnf=None):
     """Do something and measure it's impact"""
-    size=db.getSize()
-    mem=VmSize()
-    t=time.time()
-    c=time.clock()
-    r=apply(f, args)
-    t=time.time() - t
-    c=time.clock() - c
-    size=db.getSize()-size
-    mem=VmSize()-mem
-    if returnf is not None: returnf(t, c, size, mem, r)
-    else: return t, c, size, mem, r
+    t = c = size = mem = r = None
+    try:
+        size=db.getSize()
+        mem=VmSize()
+        t=time.time()
+        c=time.clock()
+        r=apply(f, args)
+        t=time.time() - t
+        c=time.clock() - c
+        size=db.getSize()-size
+        mem=VmSize()-mem
+    finally:
+        if returnf is not None:
+            returnf(t, c, size, mem, r)
+        else:
+            return t, c, size, mem, r
 
 def loadmessage(dest, message, i, body=None, headers=None):
     if body is None: body=message.fp.read()
@@ -189,7 +194,7 @@
     print
     get_transaction().commit()
 
-def loadinc(name, mb, printstat=0, max=99999999, wait=1):
+def loadinc(name, mb, f, printstat=0, max=99999999, wait=1):
     from ZODB.POSException import ConflictError
     from time import sleep
     from whrandom import uniform
@@ -351,7 +356,8 @@
         amin=min+i*count
         dest='maili%s' % amin
         initmaili(dest)
-        mb=mailbox.UnixMailbox(open(mbox))
+        f = open(mbox)
+        mb=mailbox.UnixMailbox(f)
         j=0
         while j < amin:
             mb.next()
@@ -361,7 +367,7 @@
         def returnf(t, c, size, mem, r, lock=lock):
             print c, r
             lock.release()
-        argss.append((lock, (dest, mb, 0, count, wait), returnf))
+        argss.append((lock, (dest, mb, f, 1, count, wait), returnf))
 
     for lock, args, returnf in argss:
         thread.start_new_thread(do, (Zope.DB, loadinc, args, returnf))