add command line wrapper for lbrynet-daemon calls

This commit is contained in:
Jack 2016-07-06 02:17:38 -04:00
parent 1984132eae
commit 257e38de12
2 changed files with 38 additions and 1 deletions

View file

@ -0,0 +1,36 @@
import sys
import json
from lbrynet.conf import API_CONNECTION_STRING, LOG_FILE_NAME
from jsonrpc.proxy import JSONRPCProxy
api = JSONRPCProxy.from_url(API_CONNECTION_STRING)
try:
s = api.is_running()
except:
print "lbrynet-daemon isn't running"
def main():
args = sys.argv[1:]
meth = args[0]
if len(args) > 1:
if isinstance(args[1], dict):
params = args[1]
elif isinstance(args[1], str) or isinstance(args[1], unicode):
params = json.loads(args[1])
else:
params = None
if meth in api.help():
if params:
r = api.call(meth, params)
else:
r = api.call(meth)
print r
else:
print "Unrecognized function"
if __name__ == '__main__':
main()

View file

@ -21,7 +21,8 @@ console_scripts = ['lbrynet-console = lbrynet.lbrynet_console.LBRYConsole:launch
'lbrynet-lookup-hosts-for-hash = lbrynet.dht_scripts:get_hosts_for_hash_in_dht', 'lbrynet-lookup-hosts-for-hash = lbrynet.dht_scripts:get_hosts_for_hash_in_dht',
'lbrynet-announce_hash_to_dht = lbrynet.dht_scripts:announce_hash_to_dht', 'lbrynet-announce_hash_to_dht = lbrynet.dht_scripts:announce_hash_to_dht',
'lbrynet-daemon = lbrynet.lbrynet_daemon.LBRYDaemonControl:start', 'lbrynet-daemon = lbrynet.lbrynet_daemon.LBRYDaemonControl:start',
'stop-lbrynet-daemon = lbrynet.lbrynet_daemon.LBRYDaemonControl:stop'] 'stop-lbrynet-daemon = lbrynet.lbrynet_daemon.LBRYDaemonControl:stop',
'lbrynet-cli = lbrynet.lbrynet_daemon.LBRYDaemonCLI:main']
requires = ['pycrypto', 'twisted', 'miniupnpc', 'yapsy', 'seccure', requires = ['pycrypto', 'twisted', 'miniupnpc', 'yapsy', 'seccure',
'python-bitcoinrpc==0.1', 'txJSON-RPC', 'requests>=2.4.2', 'unqlite==0.2.0', 'python-bitcoinrpc==0.1', 'txJSON-RPC', 'requests>=2.4.2', 'unqlite==0.2.0',