""" import json from basicrpc import Proxy from config import DEFAULT_SERVER, DEFAULT_PORT, DEBUG def format_response(response): try: response = response[0] except: pass return json.dumps(response, sort_keys=True, indent=4, separators=(',', ': ')) # ------------------------------ if __name__ == '__main__': c = Proxy(DEFAULT_SERVER, DEFAULT_PORT) resp = c.ping() print format_response(resp) resp = c.stats() print format_response(resp) key = {"name": "Muneeb Ali"} #resp = c.dht_get(key) #print format_response(resp)
data = fin.read() data = json.loads(data) counter = 0 for entry in data: print '-' * 5 print "Processing key: %s" % entry['key'] key = entry['key'] value = entry['value'] print "(%s, %s)" % (key, value) try: dht_client = Proxy(DEFAULT_SERVER, MIRROR_TCP_PORT, timeout=5) resp = dht_client.dht_set(key, value) print resp counter += 1 print counter print '-' * 5 except Exception as e: print e print "Problem with key: %s" % key # ------------------------------ if __name__ == '__main__': pretty_print(dht_client.ping()) #pretty_print(c.stats()) refresh_dht_entries()
data = json.loads(data) counter = 0 for entry in data: print '-' * 5 print "Processing key: %s" % entry['key'] key = entry['key'] value = entry['value'] print "(%s, %s)" % (key, value) try: dht_client = Proxy(DEFAULT_SERVER, MIRROR_TCP_PORT, timeout=5) resp = dht_client.dht_set(key, value) print resp counter += 1 print counter print '-' * 5 except Exception as e: print e print "Problem with key: %s" % key # ------------------------------ if __name__ == '__main__': pretty_print(dht_client.ping()) #pretty_print(c.stats()) refresh_dht_entries()
from config import DEFAULT_SERVER, DEFAULT_PORT, DEBUG def format_response(response): try: response = response[0] except: pass return json.dumps(response, sort_keys=True, indent=4, separators=(',', ': ')) # ------------------------------ if __name__ == '__main__': c = Proxy(DEFAULT_SERVER, DEFAULT_PORT) resp = c.ping() print format_response(resp) resp = c.stats() print format_response(resp) key = {"name": "Muneeb Ali"} #resp = c.dht_get(key) #print format_response(resp)