Skip to content

Commit

Permalink
Fix #232 and use red for all errors
Browse files Browse the repository at this point in the history
  • Loading branch information
nikochiko authored Jan 2, 2020
1 parent cc9a93b commit 7e44697
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion evalai/add_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
2 changes: 1 addition & 1 deletion evalai/get_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
4 changes: 2 additions & 2 deletions evalai/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ 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)
with open(str(AUTH_TOKEN_PATH), "w+") as TokenFile:
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))
4 changes: 2 additions & 2 deletions evalai/set_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -58,4 +58,4 @@ def host(set_host):
)
)
except (OSError, IOError) as e:
echo(e)
echo(style(str(e), bold=True, fg="red"))
2 changes: 1 addition & 1 deletion evalai/submissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions evalai/utils/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"))
18 changes: 9 additions & 9 deletions evalai/utils/challenges.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions evalai/utils/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions evalai/utils/submissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions evalai/utils/teams.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 7e44697

Please sign in to comment.