[Zope-Checkins] CVS: Zope/lib/python/Products/ZCatalog/regressiontests - loadmail.py:1.3
Barry Warsaw
barry@wooz.org
Tue, 16 Jul 2002 16:31:59 -0400
Update of /cvs-repository/Zope/lib/python/Products/ZCatalog/regressiontests
In directory cvs.zope.org:/tmp/cvs-serv3868
Modified Files:
loadmail.py
Log Message:
Fix the path in the example usage to reflect reality.
loadmail(): Make max<0 mean there's no max instead of using
bunch-o-9's. Also change the base command so that max is optional
(there'll be no max if not given).
Also, get rid of the .invalidate(None) call since 1) the method
doesn't accept a None argument anymore; 2) minimize() should do the
trick anyway.
=== Zope/lib/python/Products/ZCatalog/regressiontests/loadmail.py 1.2 => 1.3 ===
Usage:
cd lib/python
- python Products/ZCatalog/tests/loadmail.py command args
+ python Products/ZCatalog/regressiontests/loadmail.py command args
-where each command has it's own command-line arguments that it expects.
+where each command has its own command-line arguments that it expects.
Note that all of the commands operate on the Zope database,
typically var/Data.fs.
@@ -27,7 +27,7 @@
Commands:
- base mbox max
+ base mbox [max]
Build a base database by:
@@ -152,7 +152,7 @@
try: doc.manage_addProperty(name, v, type)
except: pass
-def loadmail(dest, name, mbox, printstat=0, max=99999999):
+def loadmail(dest, name, mbox, printstat=0, max=-1):
try:
import Products.BTreeFolder.BTreeFolder
@@ -167,13 +167,16 @@
i=0
message=mb.next()
while message:
- if i > max: break
+ if max >= 0 and i > max:
+ break
if i%100 == 0 and printstat:
- sys.stdout.write("\t%s\t%s\t\r" % (i, f.tell()))
+ fmt = "\t%s\t%s\t\r"
+ if os.environ.get('TERM') == 'emacs':
+ fmt = "\t%s\t%s\t\n"
+ sys.stdout.write(fmt % (i, f.tell()))
sys.stdout.flush()
if i and (i%5000 == 0):
get_transaction().commit()
- dest._p_jar._cache.invalidate(None)
dest._p_jar._cache.minimize()
loadmessage(dest, message, i)
@@ -247,7 +250,10 @@
except: pass
import Zope
app=Zope.app()
- max=atoi(sys.argv[3])
+ if len(sys.argv) > 3:
+ max = atoi(sys.argv[3])
+ else:
+ max = -1
print do(Zope.DB, loadmail, (app, 'mail', sys.argv[2], 1, max))
Zope.DB.close()