diff --git a/augur/application/cli/__init__.py b/augur/application/cli/__init__.py index 998f341e2..e68af307b 100644 --- a/augur/application/cli/__init__.py +++ b/augur/application/cli/__init__.py @@ -17,10 +17,12 @@ def test_connection(function_internet_connection): @click.pass_context def new_func(ctx, *args, **kwargs): usage = re.search(r"Usage:\s(.*)\s\[OPTIONS\]", str(ctx.get_usage())).groups()[0] + success = False with httpx.Client() as client: try: _ = client.request( method="GET", url="http://chaoss.community", timeout=10, follow_redirects=True) + success = True except (TimeoutError, httpx.TimeoutException): print("Request timed out.") except httpx.NetworkError as e: @@ -29,12 +31,16 @@ def new_func(ctx, *args, **kwargs): except httpx.ProtocolError as e: print(f"Protocol Error: {httpx.ProtocolError}") print(traceback.format_exc()) - - print(f"\n\n{usage} command setup failed\n \ - There was an error while testing for network connectivity.\n \ - Please check your connection to the internet to run Augur\n \ - Consider setting http_proxy variables for limited access installations.") - sys.exit(-1) + + if not success: + print( + f""" + \n\n{usage} command setup failed. + There was an error while testing for network connectivity + Please check your connection to the internet to run Augur + Consider setting http_proxy variables for limited access installations.""" + ) + sys.exit(-1) return ctx.invoke(function_internet_connection, *args, **kwargs)