show not connected error in lbrynet-cli when using auth

This commit is contained in:
Jack Robison 2018-04-03 12:25:18 -04:00
parent ca73d632d3
commit 12d378af13
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2

View file

@ -10,6 +10,7 @@ from lbrynet.daemon.auth.client import JSONRPCException, LBRYAPIClient, AuthAPIC
from lbrynet.daemon.Daemon import LOADING_WALLET_CODE, Daemon from lbrynet.daemon.Daemon import LOADING_WALLET_CODE, Daemon
from lbrynet.core.system_info import get_platform from lbrynet.core.system_info import get_platform
from jsonrpc.common import RPCError from jsonrpc.common import RPCError
from requests.exceptions import ConnectionError
from urllib2 import URLError, HTTPError from urllib2 import URLError, HTTPError
from httplib import UNAUTHORIZED from httplib import UNAUTHORIZED
@ -87,11 +88,11 @@ def main():
kwargs = set_flag_vals(flag_names, parsed) kwargs = set_flag_vals(flag_names, parsed)
colorama.init() colorama.init()
conf.initialize_settings() conf.initialize_settings()
api = LBRYAPIClient.get_client()
try: try:
api = LBRYAPIClient.get_client()
status = api.status() status = api.status()
except URLError as err: except (URLError, ConnectionError) as err:
if isinstance(err, HTTPError) and err.code == UNAUTHORIZED: if isinstance(err, HTTPError) and err.code == UNAUTHORIZED:
api = AuthAPIClient.config() api = AuthAPIClient.config()
# this can happen if the daemon is using auth with the --http-auth flag # this can happen if the daemon is using auth with the --http-auth flag