Unverified Commit 4764db2b authored by Julien Palard's avatar Julien Palard
Browse files

Allow to update the env from the pre-check script.

parent 981672b3
......@@ -4,6 +4,7 @@ celery -A hkis worker
import asyncio
from functools import partial
import json
from random import choice
from typing import Optional
import os
......@@ -145,7 +146,7 @@ def congrats(language):
def run_pre_check(tmpdir, pre_check: str, env=None):
def run_pre_check(tmpdir, pre_check: str, env=None) -> dict:
"""Run a pre-check script outside the sandbox before the actual check."""
with open(os.path.join(tmpdir, "pre_check.py"), "w") as pre_check_file:
......@@ -165,6 +166,10 @@ def run_pre_check(tmpdir, pre_check: str, env=None):
return json.loads(pre_check_result.stdout)
except json.JSONDecodeError:
return {}
......@@ -181,7 +186,9 @@ def check_answer_task(answer: dict):
if "language" in answer:
firejail_env["LANGUAGE"] = answer["language"]
if "pre_check" in answer and answer["pre_check"]:
run_pre_check(tmpdir, answer["pre_check"], env=firejail_env)
prof_proc = Popen(
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment