[Zodb-checkins] CVS: StandaloneZODB/Tools - zeopack.py:1.2

Jeremy Hylton jeremy@zope.com
Wed, 30 Jan 2002 15:55:40 -0500


Update of /cvs-repository/StandaloneZODB/Tools
In directory cvs.zope.org:/tmp/cvs-serv29218

Modified Files:
	zeopack.py 
Log Message:
Support -d option to specify days


=== StandaloneZODB/Tools/zeopack.py 1.1 => 1.2 ===
 Options:
 
-    -p -- port to connect to
+    -p port -- port to connect to
     
-    -h -- host to connect to (default is current host)
+    -h host -- host to connect to (default is current host)
     
-    -U -- Unix-domain socket to connect to
+    -U path -- Unix-domain socket to connect to
     
-    -S -- storage name (default is '1')
+    -S name -- storage name (default is '1')
+
+    -d days -- pack objects more than days old
 
 You must specify either -p and -h or -U.
 """
 
 from ZEO.ClientStorage import ClientStorage
 
-def main(addr, storage):
+def main(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().
     cs._startup()
-    cs.pack(wait=1)
+    cs.pack(wait=1, days=0)
 
 def usage(exit=1):
     print __doc__
@@ -41,16 +43,23 @@
     port = None
     unix = None
     storage = '1'
-    opts, args = getopt.getopt(sys.argv[1:], 'p:h:U:S:')
-    for o, a in opts:
-        if o == '-p':
-            port = int(a)
-        elif o == '-h':
-            host = a
-        elif o == '-U':
-            unix = a
-        elif o == '-S':
-            storage = a
+    days = 0
+    try:
+        opts, args = getopt.getopt(sys.argv[1:], 'p:h:U:S:d:')
+        for o, a in opts:
+            if o == '-p':
+                port = int(a)
+            elif o == '-h':
+                host = a
+            elif o == '-U':
+                unix = a
+            elif o == '-S':
+                storage = a
+            elif o == '-d':
+                days = int(a)
+    except Exception, err:
+        print err
+        usage()
 
     if unix is not None:
         addr = unix
@@ -61,4 +70,4 @@
             usage()
         addr = host, port
     
-    main(addr, storage)
+    main(addr, storage, days)