From 1c5a97ba6597584b690f993a2f5da8da8d4c2cd1 Mon Sep 17 00:00:00 2001 From: virusdefender Date: Wed, 28 Sep 2016 21:22:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=A4=9A=E8=AF=AD=E8=A8=80?= =?UTF-8?q?=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client.py | 34 ++++++++++++++++++++++++---------- languages.py | 8 ++++---- server.py | 1 - 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/client.py b/client.py index f8eeb66..4fdfee0 100644 --- a/client.py +++ b/client.py @@ -6,11 +6,10 @@ import time import requests -from utils import make_signature +from utils import make_signature, check_signature from languages import c_lang_config, c_lang_spj_config, cpp_lang_config, java_lang_config -submission_id = str(int(time.time())) token = hashlib.sha256("token").hexdigest() c_src = r""" @@ -31,7 +30,6 @@ using namespace std; int main() { int a,b; - while(1); cin >> a >> b; cout << a+b << endl; return 0; @@ -51,21 +49,37 @@ public class Main{ """ -def judge(): +def judge(src, language_config, submission_id): data = make_signature(token=token, - language_config=java_lang_config, + language_config=language_config, submission_id=submission_id, - src=java_src, + src=src, max_cpu_time=1000, max_memory=1024 * 1024 * 1024, test_case_id="d28280c6f3c5ddeadfecc3956a52da3a") r = requests.post("http://123.57.151.42:11235/judge", data=json.dumps(data)) - print r.json() + data = r.json() + check_signature(token=token, **data) + result = json.loads(data["data"]) + if result["err"]: + return result["data"] + return json.loads(data["data"])["data"] def ping(): data = make_signature(token=token) r = requests.post("http://123.57.151.42:11235/ping", data=json.dumps(data)) - print r.json() + data = r.json() -ping() -judge() + check_signature(token=token, **data) + result = json.loads(data["data"]) + if result["err"]: + return result["data"] + return json.loads(data["data"])["data"] + + +print ping() +print judge(c_src, c_lang_config, str(int(time.time()))) +time.sleep(2) +print judge(cpp_src, cpp_lang_config, str(int(time.time()))) +time.sleep(2) +print judge(java_src, java_lang_config, str(int(time.time()))) diff --git a/languages.py b/languages.py index c408ef0..2876900 100644 --- a/languages.py +++ b/languages.py @@ -13,8 +13,8 @@ c_lang_config = { }, "run": { "command": "{exe_path}", - "seccomp_rule": "c_cpp", - "max_process_number": 5 + "seccomp_rule": None, + "max_process_number": -1 } } @@ -44,8 +44,8 @@ cpp_lang_config = { }, "run": { "command": "{exe_path}", - "seccomp_rule": "c_cpp", - "max_process_number": 5 + "seccomp_rule": None, + "max_process_number": -1 } } diff --git a/server.py b/server.py index d684dc0..f7e19c1 100644 --- a/server.py +++ b/server.py @@ -70,7 +70,6 @@ class JudgeServer(object): def judge(self, language_config, submission_id, src, max_cpu_time, max_memory, test_case_id): # init compile_config = language_config["compile"] - spj_compile_config = language_config.get("spj_compile") with InitSubmissionEnv(JUDGER_WORKSPACE_BASE, submission_id=submission_id) as submission_dir: src_path = os.path.join(submission_dir, compile_config["src_name"])