From 7e446976fab2f22be6462b673622fd94b9243147 Mon Sep 17 00:00:00 2001 From: Kaustubh Maske Patil <37668193+nikochiko@users.noreply.github.com> Date: Thu, 2 Jan 2020 17:25:22 +0530 Subject: [PATCH] Fix #232 and use red for all errors --- evalai/add_token.py | 2 +- evalai/get_token.py | 2 +- evalai/login.py | 4 ++-- evalai/set_host.py | 4 ++-- evalai/submissions.py | 2 +- evalai/utils/auth.py | 4 ++-- evalai/utils/challenges.py | 18 +++++++++--------- evalai/utils/requests.py | 4 ++-- evalai/utils/submissions.py | 6 +++--- evalai/utils/teams.py | 6 +++--- 10 files changed, 26 insertions(+), 26 deletions(-) diff --git a/evalai/add_token.py b/evalai/add_token.py index cdb9c3abd..08ace52bd 100644 --- a/evalai/add_token.py +++ b/evalai/add_token.py @@ -27,7 +27,7 @@ def set_token(auth_token): auth_token = json.dumps(auth_token) fw.write(auth_token) except (OSError, IOError) as e: - echo(e) + echo(style(str(e), bold=True, fg="red")) echo( style( "Success: Authentication token is successfully set.", diff --git a/evalai/get_token.py b/evalai/get_token.py index b841ea1d6..e35d615f0 100644 --- a/evalai/get_token.py +++ b/evalai/get_token.py @@ -29,4 +29,4 @@ def get_token(): tokendata = json.loads(data) echo("Current token is {}".format(tokendata["token"])) except (OSError, IOError) as e: - echo(e) + echo(style(str(e), bold=True, fg="red")) diff --git a/evalai/login.py b/evalai/login.py index 001f2676c..6ee32f0e8 100644 --- a/evalai/login.py +++ b/evalai/login.py @@ -22,7 +22,7 @@ def login(ctx): try: json.dump(token, TokenFile) except (OSError, IOError) as e: - echo(e) + echo(style(str(e), bold=True, fg="red")) else: if not os.path.exists(AUTH_TOKEN_DIR): os.makedirs(AUTH_TOKEN_DIR) @@ -30,6 +30,6 @@ def login(ctx): try: json.dump(token, TokenFile) except (OSError, IOError) as e: - echo(e) + echo(style(str(e), bold=True, fg="red")) echo(style("\nLogged in successfully!", bold=True)) diff --git a/evalai/set_host.py b/evalai/set_host.py index f9be2e91b..667975aea 100644 --- a/evalai/set_host.py +++ b/evalai/set_host.py @@ -23,7 +23,7 @@ def host(set_host): try: fw.write(set_host) except (OSError, IOError) as e: - echo(e) + echo(style(str(e), bold=True, fg="red")) echo( style( "{} is set as the host url.".format(set_host), @@ -58,4 +58,4 @@ def host(set_host): ) ) except (OSError, IOError) as e: - echo(e) + echo(style(str(e), bold=True, fg="red")) diff --git a/evalai/submissions.py b/evalai/submissions.py index ac8bccf62..d00b66b76 100644 --- a/evalai/submissions.py +++ b/evalai/submissions.py @@ -242,7 +242,7 @@ def download_file(url): response = requests.get(signed_url, stream=True) response.raise_for_status() except requests.exceptions.HTTPError as err: - echo(err) + echo(style(str(err), bold=True, fg="red")) sys.exit(1) except requests.exceptions.RequestException: echo( diff --git a/evalai/utils/auth.py b/evalai/utils/auth.py index e18f41bbc..91e912bb7 100644 --- a/evalai/utils/auth.py +++ b/evalai/utils/auth.py @@ -59,7 +59,7 @@ def get_user_auth_token(): try: data = TokenObj.read() except (OSError, IOError) as e: - echo(style(e, bold=True, fg="red")) + echo(style(str(e), bold=True, fg="red")) data = json.loads(data) token = data["token"] return token @@ -97,4 +97,4 @@ def get_host_url(): data = fr.read() return str(data) except (OSError, IOError) as e: - echo(style(e, bold=True, fg="red")) + echo(style(str(e), bold=True, fg="red")) diff --git a/evalai/utils/challenges.py b/evalai/utils/challenges.py index 040de40b6..bc5642caa 100644 --- a/evalai/utils/challenges.py +++ b/evalai/utils/challenges.py @@ -65,7 +65,7 @@ def display_challenges(url): except requests.exceptions.HTTPError as err: if response.status_code == 401: validate_token(response.json()) - echo(err) + echo(style(str(err), bold=True, fg="red")) sys.exit(1) except requests.exceptions.RequestException: echo( @@ -116,7 +116,7 @@ def display_ongoing_challenge_list(): except requests.exceptions.HTTPError as err: if response.status_code == 401: validate_token(response.json()) - echo(err) + echo(style(str(err), bold=True, fg="red")) sys.exit(1) except requests.exceptions.RequestException: echo( @@ -169,7 +169,7 @@ def get_participant_or_host_teams(url): except requests.exceptions.HTTPError as err: if response.status_code == 401: validate_token(response.json()) - echo(err) + echo(style(str(err), bold=True, fg="red")) sys.exit(1) except requests.exceptions.RequestException: echo( @@ -200,7 +200,7 @@ def get_participant_or_host_team_challenges(url, teams): except requests.exceptions.HTTPError as err: if response.status_code == 401: validate_token(response.json()) - echo(err) + echo(style(str(err), bold=True, fg="red")) sys.exit(1) except requests.exceptions.RequestException: echo( @@ -336,7 +336,7 @@ def display_challenge_details(challenge): ) ) else: - echo(err) + echo(style(str(err), bold=True, fg="red")) sys.exit(1) except requests.exceptions.RequestException: echo( @@ -410,7 +410,7 @@ def display_challenge_phase_list(challenge_id): ) ) else: - echo(err) + echo(style(str(err), bold=True, fg="red")) sys.exit(1) except requests.exceptions.RequestException: echo( @@ -515,7 +515,7 @@ def display_challenge_phase_detail(challenge_id, phase_id, is_json): ) ) else: - echo(err) + echo(style(str(err), bold=True, fg="red")) sys.exit(1) except requests.exceptions.RequestException: echo( @@ -583,7 +583,7 @@ def display_challenge_phase_split_list(challenge_id): ) ) else: - echo(err) + echo(style(str(err), bold=True, fg="red")) sys.exit(1) except requests.exceptions.RequestException: echo( @@ -646,7 +646,7 @@ def display_leaderboard(challenge_id, phase_split_id): ) ) else: - echo(err) + echo(style(str(err), bold=True, fg="red")) sys.exit(1) except requests.exceptions.RequestException: echo( diff --git a/evalai/utils/requests.py b/evalai/utils/requests.py index 99b7b0d5d..daaa09011 100644 --- a/evalai/utils/requests.py +++ b/evalai/utils/requests.py @@ -29,7 +29,7 @@ def make_request(path, method, files=None, data=None): ) ) else: - echo(err) + echo(style(str(err), bold=True, fg="red")) sys.exit(1) except requests.exceptions.RequestException: echo( @@ -67,7 +67,7 @@ def make_request(path, method, files=None, data=None): ) ) else: - echo(err) + echo(style(str(err), bold=True, fg="red")) sys.exit(1) except requests.exceptions.RequestException: echo( diff --git a/evalai/utils/submissions.py b/evalai/utils/submissions.py index 19d9fc3e4..616c085ae 100644 --- a/evalai/utils/submissions.py +++ b/evalai/utils/submissions.py @@ -49,7 +49,7 @@ def make_submission(challenge_id, phase_id, file, submission_metadata={}): ) ) else: - echo(err) + echo(style(str(err), bold=True, fg="red")) if "input_file" in response.json(): echo(style(response.json()["input_file"][0], fg="red", bold=True)) sys.exit(1) @@ -169,7 +169,7 @@ def display_my_submission_details( ) ) else: - echo(err) + echo(style(str(err), bold=True, fg="red")) sys.exit(1) except requests.exceptions.RequestException: echo( @@ -241,7 +241,7 @@ def submission_details_request(submission_id): ) ) else: - echo(err) + echo(style(str(err), bold=True, fg="red")) sys.exit(1) except requests.exceptions.RequestException: echo( diff --git a/evalai/utils/teams.py b/evalai/utils/teams.py index ca06011ba..f2e7f31cb 100644 --- a/evalai/utils/teams.py +++ b/evalai/utils/teams.py @@ -72,7 +72,7 @@ def display_teams(is_host): ) ) else: - echo(err) + echo(style(str(err), bold=True, fg="red")) sys.exit(1) except requests.exceptions.RequestException: echo( @@ -136,7 +136,7 @@ def create_team(team_name, team_url, is_host): ) ) else: - echo(err) + echo(style(str(err), bold=True, fg="red")) sys.exit(1) except requests.exceptions.RequestException: echo( @@ -200,7 +200,7 @@ def participate_in_a_challenge(challenge_id, participant_team_id): ) ) else: - echo(err) + echo(style(str(err), bold=True, fg="red")) sys.exit(1) except requests.exceptions.RequestException: echo(