From 40998e10c4e1f428ae4e564021834b9059451331 Mon Sep 17 00:00:00 2001 From: Jeremy Hylton <jeremy@svn.zope.org> Date: Wed, 30 Jan 2002 20:55:38 +0000 Subject: [PATCH] Support -d option to specify days --- src/scripts/tests/testzeopack.py | 6 +++++ src/scripts/zeopack.py | 43 +++++++++++++++++++------------- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/src/scripts/tests/testzeopack.py b/src/scripts/tests/testzeopack.py index 49ba1e5b..62eb36b4 100644 --- a/src/scripts/tests/testzeopack.py +++ b/src/scripts/tests/testzeopack.py @@ -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() diff --git a/src/scripts/zeopack.py b/src/scripts/zeopack.py index a66c307d..9500de2b 100755 --- a/src/scripts/zeopack.py +++ b/src/scripts/zeopack.py @@ -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) -- 2.30.9