Commit 40998e10 authored by Jeremy Hylton's avatar Jeremy Hylton

Support -d option to specify days

parent fcaa1e26
......@@ -60,6 +60,12 @@ class PackerTests(StorageTestBase):
os.system("zeopack.py -h %s -p %s" % (self.host, self.port))
assert os.path.exists(self.path + ".old")
def testPackDays(self):
self.set_inet_addr()
self.start()
os.system("zeopack.py -h %s -p %s -d 1" % (self.host, self.port))
assert os.path.exists(self.path + ".old")
def testAF_UNIXPack(self):
self.addr = tempfile.mktemp(suffix=".zeo-socket")
self.start()
......
......@@ -5,27 +5,29 @@ Usage: zeopack.py [options]
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 @@ if __name__ == "__main__":
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 @@ if __name__ == "__main__":
usage()
addr = host, port
main(addr, storage)
main(addr, storage, days)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment