Skip to content

Commit

Permalink
Use a log file to write error log
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonGrace2282 committed Sep 12, 2024
1 parent c94e702 commit 45161a3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion docs/source/usage/graders/examples/addition.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

import importlib.util
import sys
import traceback
from collections.abc import Callable
from pathlib import Path

student_code_path: str = sys.argv[2]
username: str = sys.argv[3]
log_file = Path(sys.argv[4])

test_cases = (
(1, 2),
Expand Down Expand Up @@ -40,8 +44,9 @@ def import_module(modname: str = "student_submission", func_name="add_num") -> C
try:
spec.loader.exec_module(submission)
except Exception:
# this traceback could provide sensitive information, so we don't provide it
# this traceback could provide sensitive information, so we don't provide it to students
print("Could not test submission, an exception was raised while initializing.")
log_file.write_text(f"Student {username} import error:\n\n" + traceback.format_exc())
# it's not our fault so we exit 0
sys.exit(0)

Expand Down

0 comments on commit 45161a3

Please sign in to comment.