Skip to content

Commit

Permalink
Logical fixes and general improvements
Browse files Browse the repository at this point in the history
- Fix logical issue with try block
- Use multiline string for logging

Signed-off-by: Ulincsys <ulincsys@gmail.com>
  • Loading branch information
Ulincsys committed Feb 17, 2025
1 parent 53c3c14 commit 6954f9c
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions augur/application/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)

Expand Down

0 comments on commit 6954f9c

Please sign in to comment.