From cea4eca77562c1ed82203e2154b392abbf9adb6f Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Thu, 9 Feb 2017 10:44:29 -0500 Subject: [PATCH] update example script --- README.md | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e2e2374d1..2015e9c12 100644 --- a/README.md +++ b/README.md @@ -40,18 +40,28 @@ know all of the necessary chunks. The bundled LBRY application uses the lbrynet JSONRPC api found in `lbrynet.lbrynet_daemon.LBRYDaemon`. This api allows for applications and web services like the lbry browser UI to interact with lbrynet. If you've installed lbrynet, you can run `lbrynet-daemon` without running the app. While the app or `lbrynet-daemon` is running, you can use the following to show the help for all the available commands: ``` -from jsonrpc.proxy import JSONRPCProxy +import sys try: - from lbrynet.conf import API_CONNECTION_STRING + from lbrynet import conf + from lbrynet.lbrynet_daemon.auth.client import LBRYAPIClient +except ImportError: + print "You don't have lbrynet installed!" + sys.exit(0) + +conf.initialize_settings() +api = LBRYAPIClient.get_client() + +try: + status = api.status() except: - print "You don't have lbrynet installed!" - API_CONNECTION_STRING = "http://localhost:5279/lbryapi" - -api = JSONRPCProxy.from_url(API_CONNECTION_STRING) -status = api.status() + print "lbrynet-daemon isn't running!" + sys.exit(0) + if not status['is_running']: - print status + print "lbrynet-daemon hasn't finished starting up, here's the status message:" + print status + sys.exit(0) else: for cmd in api.commands(): print "%s:\n%s" % (cmd, api.help({'command': cmd}))