diff --git a/client/Python/client.py b/client/Python/client.py index 4725743..9b1250a 100644 --- a/client/Python/client.py +++ b/client/Python/client.py @@ -46,9 +46,9 @@ class JudgeServerClient(object): "output": output} return self._request(self.server_base_url + "/judge", data=data) - def compile_spj(self, src, spj_version, spj_compile_config, test_case_id): + def compile_spj(self, src, spj_version, spj_compile_config): data = {"src": src, "spj_version": spj_version, - "spj_compile_config": spj_compile_config, "test_case_id": test_case_id} + "spj_compile_config": spj_compile_config} return self._request(self.server_base_url + "/compile_spj", data=data) @@ -106,34 +106,43 @@ print int(s1[0]) + int(s1[1])""" s1 = s.split(" ") print(int(s1[0]) + int(s1[1]))""" - client = JudgeServerClient(token=token, server_base_url="http://test.qduoj.com:12358") + client = JudgeServerClient(token=token, server_base_url="http://127.0.0.1:12358") + print("ping") print(client.ping(), "\n\n") - print(client.compile_spj(src=c_spj_src, spj_version="2", spj_compile_config=c_lang_spj_compile, - test_case_id="spj"), "\n\n") + print("compile_spj") + print(client.compile_spj(src=c_spj_src, spj_version="2", spj_compile_config=c_lang_spj_compile + ), "\n\n") + print("c_judge") print(client.judge(src=c_src, language_config=c_lang_config, max_cpu_time=1000, max_memory=1024 * 1024 * 128, test_case_id="normal", output=True), "\n\n") + print("cpp_judge") print(client.judge(src=cpp_src, language_config=cpp_lang_config, max_cpu_time=1000, max_memory=1024 * 1024 * 128, test_case_id="normal"), "\n\n") + print("java_judge") print(client.judge(src=java_src, language_config=java_lang_config, - max_cpu_time=1000, max_memory=1024 * 1024 * 1024, + max_cpu_time=1000, max_memory=256 * 1024 * 1024, test_case_id="normal"), "\n\n") + print("c_spj_judge") print(client.judge(src=c_src, language_config=c_lang_config, max_cpu_time=1000, max_memory=1024 * 1024 * 128, test_case_id="spj", spj_version="3", spj_config=c_lang_spj_config, spj_compile_config=c_lang_spj_compile, spj_src=c_spj_src), "\n\n") + + print("py2_judge") print(client.judge(src=py2_src, language_config=py2_lang_config, max_cpu_time=1000, max_memory=128 * 1024 * 1024, test_case_id="normal"), "\n\n") + print("py3_judge") print(client.judge(src=py3_src, language_config=py3_lang_config, max_cpu_time=1000, max_memory=128 * 1024 * 1024, test_case_id="normal"), "\n\n") diff --git a/client/Python/languages.py b/client/Python/languages.py index 213dbca..bbe8a45 100644 --- a/client/Python/languages.py +++ b/client/Python/languages.py @@ -80,7 +80,7 @@ py2_lang_config = { }, "run": { "command": "/usr/bin/python {exe_path}", - "seccomp_rule": None, + "seccomp_rule": "general", "env": default_env } } @@ -96,7 +96,7 @@ py3_lang_config = { }, "run": { "command": "/usr/bin/python3 {exe_path}", - "seccomp_rule": None, + "seccomp_rule": "general", "env": ["PYTHONIOENCODING=UTF-8"] + default_env } } diff --git a/server/server.py b/server/server.py index 5cb6299..ad8702b 100644 --- a/server/server.py +++ b/server/server.py @@ -53,10 +53,13 @@ class JudgeServer(object): run_config = language_config["run"] submission_id = str(uuid.uuid4()) - if spj_version: - self.compile_spj(spj_version=spj_version, src=spj_src, - spj_compile_config=spj_compile_config, - test_case_id=test_case_id) + if spj_version and spj_config: + spj_exe_path = os.path.join(SPJ_EXE_DIR, spj_config["exe_name"].format(spj_version=spj_version)) + # spj src has not been compiled + if not os.path.isfile(spj_exe_path): + logger.warning("%s does not exists, spj src will be recompiled") + self.compile_spj(spj_version=spj_version, src=spj_src, + spj_compile_config=spj_compile_config) with InitSubmissionEnv(JUDGER_WORKSPACE_BASE, submission_id=str(submission_id)) as submission_dir: if compile_config: @@ -88,7 +91,7 @@ class JudgeServer(object): return run_result - def compile_spj(self, spj_version, src, spj_compile_config, test_case_id): + def compile_spj(self, spj_version, src, spj_compile_config): spj_compile_config["src_name"] = spj_compile_config["src_name"].format(spj_version=spj_version) spj_compile_config["exe_name"] = spj_compile_config["exe_name"].format(spj_version=spj_version)