From ecaf47fef4123ededfde70e97a9c7c2785a81ce5 Mon Sep 17 00:00:00 2001 From: virusdefender Date: Sat, 29 Apr 2017 18:30:16 +0800 Subject: [PATCH] add Python3 language support --- client/Python/client.py | 10 +++++++++- client/Python/languages.py | 16 ++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/client/Python/client.py b/client/Python/client.py index b0af6a0..4725743 100644 --- a/client/Python/client.py +++ b/client/Python/client.py @@ -7,7 +7,7 @@ import json import requests from languages import c_lang_config, cpp_lang_config, java_lang_config, c_lang_spj_config, \ - c_lang_spj_compile, py2_lang_config + c_lang_spj_compile, py2_lang_config, py3_lang_config class JudgeServerClientError(Exception): @@ -102,6 +102,10 @@ if __name__ == "__main__": s1 = s.split(" ") print int(s1[0]) + int(s1[1])""" + py3_src = """s = input() +s1 = s.split(" ") +print(int(s1[0]) + int(s1[1]))""" + client = JudgeServerClient(token=token, server_base_url="http://test.qduoj.com:12358") print(client.ping(), "\n\n") @@ -129,3 +133,7 @@ print int(s1[0]) + int(s1[1])""" 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(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 3a5a105..4ed13c6 100644 --- a/client/Python/languages.py +++ b/client/Python/languages.py @@ -84,3 +84,19 @@ py2_lang_config = { "env": default_env } } + +py3_lang_config = { + "compile": { + "src_name": "solution.py", + "exe_name": "__pycache__/solution.cpython-35.pyc", + "max_cpu_time": 3000, + "max_real_time": 5000, + "max_memory": 128 * 1024 * 1024, + "compile_command": "/usr/bin/python3 -m py_compile {src_path}", + }, + "run": { + "command": "/usr/bin/python3 {exe_path}", + "seccomp_rule": None, + "env": ["PYTHONIOENCODING=UTF-8"] + default_env + } +}