move scripts into scripts dir

This commit is contained in:
Alex Grintsvayg 2017-03-31 14:23:09 -04:00
parent 850f51140e
commit c20ba29c7a
5 changed files with 0 additions and 0 deletions

41
scripts/node_rpc_cli.py Normal file
View file

@ -0,0 +1,41 @@
"""
CLI for sending rpc commands to a DHT node
"""
from twisted.internet import reactor
from txjsonrpc.web.jsonrpc import Proxy
import argparse
def print_value(value):
print value
def print_error(err):
print err.getErrorMessage()
def shut_down():
reactor.stop()
def main():
parser = argparse.ArgumentParser(description="Send an rpc command to a dht node")
parser.add_argument("rpc_command",
help="The rpc command to send to the dht node")
parser.add_argument("--node_host",
help="The host of the node to connect to",
default="127.0.0.1")
parser.add_argument("--node_port",
help="The port of the node to connect to",
default="8888")
args = parser.parse_args()
connect_string = 'http://%s:%s' % (args.node_host, args.node_port)
proxy = Proxy(connect_string)
d = proxy.callRemote(args.rpc_command)
d.addCallbacks(print_value, print_error)
d.addBoth(lambda _: shut_down())
reactor.run()