Skip to content

Commit 7e47dbf

Browse files
authored
Merge branch 'cs50:main' into wsl-html-url
2 parents 08d9a4e + 6fd6136 commit 7e47dbf

File tree

3 files changed

+25
-17
lines changed

3 files changed

+25
-17
lines changed

Diff for: check50/__main__.py

+21-13
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import importlib
66
import inspect
77
import itertools
8+
from json import JSONDecodeError
89
import logging
910
import os
1011
import platform
@@ -139,22 +140,29 @@ def await_results(commit_hash, slug, pings=45, sleep=2):
139140
{pings} pings and waiting {sleep} seconds between pings.
140141
"""
141142

142-
for _i in range(pings):
143-
# Query for check results.
144-
res = requests.get(f"https://submit.cs50.io/api/results/check50", params={"commit_hash": commit_hash, "slug": slug})
145-
results = res.json()
143+
try:
144+
for _i in range(pings):
145+
# Query for check results.
146+
res = requests.get(f"https://submit.cs50.io/api/results/check50", params={"commit_hash": commit_hash, "slug": slug})
147+
results = res.json()
146148

147-
if res.status_code not in [404, 200]:
148-
raise _exceptions.RemoteCheckError(results)
149+
if res.status_code not in [404, 200]:
150+
raise _exceptions.RemoteCheckError(results)
149151

150-
if res.status_code == 200 and results["received_at"] is not None:
151-
break
152-
time.sleep(sleep)
153-
else:
154-
# Terminate if no response
152+
if res.status_code == 200 and results["received_at"] is not None:
153+
break
154+
time.sleep(sleep)
155+
else:
156+
# Terminate if no response
157+
raise _exceptions.Error(
158+
_("check50 is taking longer than normal!\n"
159+
"See https://submit.cs50.io/check50/{} for more detail").format(commit_hash))
160+
161+
except JSONDecodeError:
162+
# Invalid JSON object received from submit.cs50.io
155163
raise _exceptions.Error(
156-
_("check50 is taking longer than normal!\n"
157-
"See https://submit.cs50.io/check50/{} for more detail").format(commit_hash))
164+
_("Sorry, something's wrong, please try again.\n"
165+
"If the problem persists, please visit our status page https://cs50.statuspage.io for more information."))
158166

159167
if not results["check50"]:
160168
raise _exceptions.RemoteCheckError(results)

Diff for: check50/_exceptions.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Error(Exception):
1616
class RemoteCheckError(Error):
1717
"""An exception for errors that happen in check50's remote operation."""
1818
def __init__(self, remote_json):
19-
super().__init__("check50 ran into an error while running checks! Please contact sysadmins@cs50.harvard.edu!")
19+
super().__init__("check50 ran into an error while running checks! Please visit our status page https://cs50.statuspage.io for more information.")
2020
self.payload = {"remote_json": remote_json}
2121

2222

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

5353
# Output exception as json
5454
if "json" in self.outputs:

Diff for: setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@
2929
"console_scripts": ["check50=check50.__main__:main"]
3030
},
3131
url="https://github.com/cs50/check50",
32-
version="3.3.5",
32+
version="3.3.6",
3333
include_package_data=True
3434
)

0 commit comments

Comments
 (0)