[Zodb-checkins] CVS: StandaloneZODB/Tools - zeopack.py:1.5
Jeremy Hylton
jeremy@zope.com
Wed, 30 Jan 2002 17:10:09 -0500
Update of /cvs-repository/StandaloneZODB/Tools
In directory cvs.zope.org:/tmp/cvs-serv4041/Tools
Modified Files:
zeopack.py
Log Message:
Add -W option to wait forever for server.
=== StandaloneZODB/Tools/zeopack.py 1.4 => 1.5 ===
-d days -- pack objects more than days old
+ -W -- wait for server to come up. Normally the script tries to
+ connect for 10 seconds, then exits with an error.
+
You must specify either -p and -h or -U.
"""
@@ -40,14 +43,19 @@
return
raise RuntimeError, "Unable to connect to ZEO server"
-def pack(addr, storage, days):
- cs = ClientStorage(addr, storage=storage, wait_for_server_on_startup=1)
- # _startup() is an artifact of the way ZEO 1.0 works. The
- # ClientStorage doesn't get fully initialized until registerDB()
- # is called. The only thing we care about, though, is that
- # registerDB() calls _startup().
- connect(cs)
+def pack(addr, storage, days, wait):
+ cs = ClientStorage(addr, storage=storage, wait_for_server_on_startup=wait)
+ if wait:
+ # _startup() is an artifact of the way ZEO 1.0 works. The
+ # ClientStorage doesn't get fully initialized until registerDB()
+ # is called. The only thing we care about, though, is that
+ # registerDB() calls _startup().
+ cs._startup()
+ else:
+ connect(cs)
+ cs.invalidator = None
cs.pack(wait=1, days=days)
+ cs.close()
def usage(exit=1):
print __doc__
@@ -60,8 +68,9 @@
unix = None
storage = '1'
days = 0
+ wait = 0
try:
- opts, args = getopt.getopt(sys.argv[1:], 'p:h:U:S:d:')
+ opts, args = getopt.getopt(sys.argv[1:], 'p:h:U:S:d:W')
for o, a in opts:
if o == '-p':
port = int(a)
@@ -73,6 +82,8 @@
storage = a
elif o == '-d':
days = int(a)
+ elif o == '-W':
+ wait = 1
except Exception, err:
print err
usage()
@@ -86,7 +97,7 @@
usage()
addr = host, port
- pack(addr, storage, days)
+ pack(addr, storage, days, wait)
if __name__ == "__main__":
try: