加强对special judge的判断

This commit is contained in:
virusdefender 2016-10-04 14:32:40 +08:00
parent 15abb18267
commit c97b57e95a
2 changed files with 9 additions and 4 deletions

View File

@ -38,6 +38,10 @@ class JudgeClient(object):
self._spj_version = spj_version
self._spj_config = spj_config
if self._spj_version and self._spj_config:
self._spj_exe = os.path.join(self._test_case_dir, self._spj_config["exe_name"].format(spj_version=self._spj_version))
if not os.path.exists(self._spj_exe):
raise JudgeClientError("spj exe not found")
def _load_test_case_info(self):
try:
@ -62,9 +66,9 @@ class JudgeClient(object):
return output_md5, output_md5 == self._test_case_info["test_cases"][str(test_case_file_id)]["striped_output_md5"]
def _spj(self, in_file_path, user_out_file_path):
command = self._spj_config["command"].format(exe_path=os.path.join(self._test_case_dir,
self._spj_config["exe_name"].format(spj_version=self._spj_version)),
in_file_path=in_file_path, user_out_file_path=user_out_file_path).split(" ")
command = self._spj_config["command"].format(exe_path=self._spj_exe,
in_file_path=in_file_path,
user_out_file_path=user_out_file_path).split(" ")
result = _judger.run(max_cpu_time=self._max_cpu_time * 3,
max_real_time=self._max_cpu_time * 9,
max_memory=self._max_memory * 3,

View File

@ -3,6 +3,7 @@ from __future__ import unicode_literals
import os
import json
import requests
import hashlib
from exception import JudgeServiceError
from utils import server_info, get_token, logger
@ -29,7 +30,7 @@ class JudgeService(object):
def _request(self, data):
try:
r = requests.post(self.service_discovery_url, data=json.dumps(data),
headers={"X-JUDGE-SERVER-TOKEN": get_token()}, timeout=5).json()
headers={"X-JUDGE-SERVER-TOKEN": hashlib.sha256(get_token()).hexdigest()}, timeout=5).json()
except Exception as e:
logger.exception(e)
raise JudgeServiceError(e.message)