forked from LBRYCommunity/lbry-sdk
avoid name errors
This commit is contained in:
parent
bc5824b8bc
commit
b98621d7ea
1 changed files with 5 additions and 2 deletions
|
@ -29,17 +29,20 @@ from lbrynet.system_info import get_platform
|
||||||
|
|
||||||
async def execute_command(method, params, conf_path=None):
|
async def execute_command(method, params, conf_path=None):
|
||||||
# this check if the daemon is running or not
|
# this check if the daemon is running or not
|
||||||
|
api = None
|
||||||
try:
|
try:
|
||||||
api = await LBRYAPIClient.get_client(conf_path)
|
api = await LBRYAPIClient.get_client(conf_path)
|
||||||
await api.status()
|
await api.status()
|
||||||
except (ClientConnectorError, ConnectionError):
|
except (ClientConnectorError, ConnectionError):
|
||||||
await api.session.close()
|
if api:
|
||||||
|
await api.session.close()
|
||||||
print("Could not connect to daemon. Are you sure it's running?")
|
print("Could not connect to daemon. Are you sure it's running?")
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
# this actually executes the method
|
# this actually executes the method
|
||||||
|
resp = await api.call(method, params)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
resp = await api.call(method, params)
|
|
||||||
await api.session.close()
|
await api.session.close()
|
||||||
print(json.dumps(resp["result"], indent=2))
|
print(json.dumps(resp["result"], indent=2))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|
Loading…
Reference in a new issue