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): ...@@ -60,6 +60,12 @@ class PackerTests(StorageTestBase):
os.system("zeopack.py -h %s -p %s" % (self.host, self.port)) os.system("zeopack.py -h %s -p %s" % (self.host, self.port))
assert os.path.exists(self.path + ".old") 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): def testAF_UNIXPack(self):
self.addr = tempfile.mktemp(suffix=".zeo-socket") self.addr = tempfile.mktemp(suffix=".zeo-socket")
self.start() self.start()
......
...@@ -5,27 +5,29 @@ Usage: zeopack.py [options] ...@@ -5,27 +5,29 @@ Usage: zeopack.py [options]
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. You must specify either -p and -h or -U.
""" """
from ZEO.ClientStorage import ClientStorage 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) cs = ClientStorage(addr, storage=storage, wait_for_server_on_startup=1)
# _startup() is an artifact of the way ZEO 1.0 works. The # _startup() is an artifact of the way ZEO 1.0 works. The
# ClientStorage doesn't get fully initialized until registerDB() # ClientStorage doesn't get fully initialized until registerDB()
# is called. The only thing we care about, though, is that # is called. The only thing we care about, though, is that
# registerDB() calls _startup(). # registerDB() calls _startup().
cs._startup() cs._startup()
cs.pack(wait=1) cs.pack(wait=1, days=0)
def usage(exit=1): def usage(exit=1):
print __doc__ print __doc__
...@@ -41,16 +43,23 @@ if __name__ == "__main__": ...@@ -41,16 +43,23 @@ if __name__ == "__main__":
port = None port = None
unix = None unix = None
storage = '1' storage = '1'
opts, args = getopt.getopt(sys.argv[1:], 'p:h:U:S:') days = 0
for o, a in opts: try:
if o == '-p': opts, args = getopt.getopt(sys.argv[1:], 'p:h:U:S:d:')
port = int(a) for o, a in opts:
elif o == '-h': if o == '-p':
host = a port = int(a)
elif o == '-U': elif o == '-h':
unix = a host = a
elif o == '-S': elif o == '-U':
storage = a unix = a
elif o == '-S':
storage = a
elif o == '-d':
days = int(a)
except Exception, err:
print err
usage()
if unix is not None: if unix is not None:
addr = unix addr = unix
...@@ -61,4 +70,4 @@ if __name__ == "__main__": ...@@ -61,4 +70,4 @@ if __name__ == "__main__":
usage() usage()
addr = host, port 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