rm.py

Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 import sys; import sha; import optparse; from xmlrpclib import *
00003 p = optparse.OptionParser(usage="usage: %prog [options] <key> <value> <secret>")
00004 p.add_option("-g", "--gateway", dest="gateway", metavar="GW",
00005              default="http://localhost:1234/", 
00006              help="gateway URI, list at http://opendht.org/servers.txt")
00007 p.add_option("-t", "--ttl", dest="ttl", default="3600", metavar="TTL", 
00008              type="int", help="must be longer than TTL remaining for value")
00009 (opts, args) = p.parse_args()
00010 if (len(args) < 3): p.print_help(); sys.exit(1)
00011 pxy = ServerProxy(opts.gateway); res = {0:"Success", 1:"Capacity", 2:"Again"}
00012 key = Binary(sha.new(args[0]).digest()); ttl = int(opts.ttl); 
00013 vh = Binary(sha.new(args[1]).digest()); sec = Binary(args[2]) 
00014 print res[pxy.rm(key, vh, "SHA", sec, ttl, "rm.py")]

Generated on Fri Mar 20 18:40:26 2009 for OverSim by  doxygen 1.5.5