更新部分配置

This commit is contained in:
virusdefender 2016-10-05 13:38:49 +08:00
parent c97b57e95a
commit 32b1017299
2 changed files with 9 additions and 9 deletions

View File

@ -12,7 +12,6 @@ from config import TEST_CASE_DIR, JUDGER_RUN_LOG_PATH, LOW_PRIVILEDGE_GID, LOW_P
from exception import JudgeClientError
WA = -1
SPJ_WA = 1
SPJ_AC = 0
SPJ_ERROR = -1
@ -86,7 +85,8 @@ class JudgeClient(object):
gid=LOW_PRIVILEDGE_GID)
if result["result"] == _judger.RESULT_SUCCESS or \
(result["result"] == _judger.RESULT_RUNTIME_ERROR and result["exit_code"] in [SPJ_WA, SPJ_ERROR]):
(result["result"] == _judger.RESULT_RUNTIME_ERROR and
result["exit_code"] in [SPJ_WA, SPJ_ERROR] and result["signal"] == 0):
return result["exit_code"]
else:
return SPJ_ERROR
@ -124,14 +124,15 @@ class JudgeClient(object):
spj_result = self._spj(in_file_path=in_file, user_out_file_path=out_file)
if spj_result == SPJ_WA:
run_result["result"] = WA
run_result["result"] = _judger.RESULT_WRONG_ANSWER
elif spj_result == SPJ_ERROR:
run_result["result"] = _judger.RESULT_SYSTEM_ERROR
run_result["error"] = _judger.RESULT_SPJ_ERROR
else:
run_result["output_md5"], is_ac = self._compare_output(test_case_file_id)
# -1 == Wrong Answer
if not is_ac:
run_result["result"] = WA
run_result["result"] = _judger.RESULT_WRONG_ANSWER
return run_result

View File

@ -17,8 +17,7 @@ class JudgeService(object):
self.service_discovery_url = os.environ.get("service_discovery_url", "")
# this container's ip and port, if these are not set, web server will think it's a linked container
self.service_host = os.environ.get("service_host")
self.service_port = os.environ.get("service_port")
self.service_url = os.environ.get("service_url")
if not self.service_discovery_url:
if not (self.service_discovery_host and self.service_discovery_port):
@ -30,7 +29,8 @@ class JudgeService(object):
def _request(self, data):
try:
r = requests.post(self.service_discovery_url, data=json.dumps(data),
headers={"X-JUDGE-SERVER-TOKEN": hashlib.sha256(get_token()).hexdigest()}, timeout=5).json()
headers={"X-JUDGE-SERVER-TOKEN": hashlib.sha256(get_token()).hexdigest(),
"Content-Type": "application/json"}, timeout=5).json()
except Exception as e:
logger.exception(e)
raise JudgeServiceError(e.message)
@ -40,8 +40,7 @@ class JudgeService(object):
def heartbeat(self):
data = server_info()
data["action"] = "heartbeat"
data["service_host"] = self.service_host
data["service_port"] = self.service_port
data["service_url"] = self.service_url
self._request(data)