完成对SPJ的支持

xml rpc不能使用None
This commit is contained in:
virusdefender
2016-04-06 20:33:19 +08:00
parent 3d396cc8e4
commit b3116cc430
11 changed files with 134 additions and 41 deletions

26
judge/spj_client.py Normal file
View File

@@ -0,0 +1,26 @@
# coding=utf-8
import os
import judger
WA = 1
AC = 0
SPJ_ERROR = -1
def file_exists(path):
return os.path.exists(path)
def spj(path, max_cpu_time, max_memory, in_path, user_out_path):
if file_exists(in_path) and file_exists(user_out_path):
result = judger.run(path=path, in_file="/dev/null", out_file="/dev/null",
max_cpu_time=max_cpu_time, max_memory=max_memory,
args=[in_path, user_out_path], env=["PATH=" + os.environ.get("PATH", "")],
use_sandbox=True, use_nobody=True)
if result["signal"] == 0 and result["exit_status"] in [AC, WA, SPJ_ERROR]:
result["spj_result"] = result["exit_status"]
else:
result["spj_result"] = SPJ_ERROR
return result
else:
raise ValueError("in_path or user_out_path does not exist")