Skip to content

Commit

Permalink
Merge branch 'cs50:main' into wsl-html-url
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRijn authored Jul 5, 2022
2 parents 08d9a4e + 6fd6136 commit 7e47dbf
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
34 changes: 21 additions & 13 deletions check50/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import importlib
import inspect
import itertools
from json import JSONDecodeError
import logging
import os
import platform
Expand Down Expand Up @@ -139,22 +140,29 @@ def await_results(commit_hash, slug, pings=45, sleep=2):
{pings} pings and waiting {sleep} seconds between pings.
"""

for _i in range(pings):
# Query for check results.
res = requests.get(f"https://submit.cs50.io/api/results/check50", params={"commit_hash": commit_hash, "slug": slug})
results = res.json()
try:
for _i in range(pings):
# Query for check results.
res = requests.get(f"https://submit.cs50.io/api/results/check50", params={"commit_hash": commit_hash, "slug": slug})
results = res.json()

if res.status_code not in [404, 200]:
raise _exceptions.RemoteCheckError(results)
if res.status_code not in [404, 200]:
raise _exceptions.RemoteCheckError(results)

if res.status_code == 200 and results["received_at"] is not None:
break
time.sleep(sleep)
else:
# Terminate if no response
if res.status_code == 200 and results["received_at"] is not None:
break
time.sleep(sleep)
else:
# Terminate if no response
raise _exceptions.Error(
_("check50 is taking longer than normal!\n"
"See https://submit.cs50.io/check50/{} for more detail").format(commit_hash))

except JSONDecodeError:
# Invalid JSON object received from submit.cs50.io
raise _exceptions.Error(
_("check50 is taking longer than normal!\n"
"See https://submit.cs50.io/check50/{} for more detail").format(commit_hash))
_("Sorry, something's wrong, please try again.\n"
"If the problem persists, please visit our status page https://cs50.statuspage.io for more information."))

if not results["check50"]:
raise _exceptions.RemoteCheckError(results)
Expand Down
6 changes: 3 additions & 3 deletions check50/_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Error(Exception):
class RemoteCheckError(Error):
"""An exception for errors that happen in check50's remote operation."""
def __init__(self, remote_json):
super().__init__("check50 ran into an error while running checks! Please contact sysadmins@cs50.harvard.edu!")
super().__init__("check50 ran into an error while running checks! Please visit our status page https://cs50.statuspage.io for more information.")
self.payload = {"remote_json": remote_json}


Expand Down Expand Up @@ -47,8 +47,8 @@ def __call__(self, cls, exc, tb):
return
else:
show_traceback = True
message = _("Sorry, something is wrong! check50 ran into an error.\n" \
"Please let CS50 know by emailing the error above to sysadmins@cs50.harvard.edu.")
message = _("Sorry, something is wrong! check50 ran into an error, please try again.\n" \
"If the problem persists, please visit our status page https://cs50.statuspage.io for more information.")

# Output exception as json
if "json" in self.outputs:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
"console_scripts": ["check50=check50.__main__:main"]
},
url="https://github.com/cs50/check50",
version="3.3.5",
version="3.3.6",
include_package_data=True
)

0 comments on commit 7e47dbf

Please sign in to comment.