From b98621d7ea0686d9092cd0e7a3013c60d4100c7b Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Wed, 7 Nov 2018 15:24:05 -0500 Subject: [PATCH] avoid name errors --- lbrynet/extras/cli.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lbrynet/extras/cli.py b/lbrynet/extras/cli.py index 3fa0dce11..78721617e 100644 --- a/lbrynet/extras/cli.py +++ b/lbrynet/extras/cli.py @@ -29,17 +29,20 @@ from lbrynet.system_info import get_platform async def execute_command(method, params, conf_path=None): # this check if the daemon is running or not + api = None try: api = await LBRYAPIClient.get_client(conf_path) await api.status() 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?") return 1 # this actually executes the method + resp = await api.call(method, params) + try: - resp = await api.call(method, params) await api.session.close() print(json.dumps(resp["result"], indent=2)) except KeyError: