detect authentication error and warn accordingly

This commit is contained in:
Alex Grintsvayg 2017-01-09 19:58:05 -05:00
parent 5c429e15bd
commit a6457d2c0a

View file

@ -7,7 +7,8 @@ from lbrynet import conf
from lbrynet.lbrynet_daemon.auth.client import JSONRPCException, LBRYAPIClient from lbrynet.lbrynet_daemon.auth.client import JSONRPCException, LBRYAPIClient
from lbrynet.lbrynet_daemon.Daemon import LOADING_WALLET_CODE from lbrynet.lbrynet_daemon.Daemon import LOADING_WALLET_CODE
from jsonrpc.common import RPCError from jsonrpc.common import RPCError
from urllib2 import URLError from urllib2 import URLError, HTTPError
from httplib import UNAUTHORIZED
def main(): def main():
@ -33,7 +34,11 @@ def main():
try: try:
status = api.status() status = api.status()
except URLError: except URLError as err:
if isinstance(err, HTTPError) and err.code == UNAUTHORIZED:
print_error("Daemon requires authentication, but none was provided.",
suggest_help=False)
else:
print_error("Could not connect to daemon. Are you sure it's running?", print_error("Could not connect to daemon. Are you sure it's running?",
suggest_help=False) suggest_help=False)
return 1 return 1