From 070974a8798bfe383bd5f8d41c4a0c181e3ddd1d Mon Sep 17 00:00:00 2001 From: Comzyh Date: Sat, 9 Jan 2016 03:25:53 +0800 Subject: [PATCH 1/3] use etcc --- judgesite/config.py | 31 +++++++++++++++++++------------ requirements.txt | 2 +- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/judgesite/config.py b/judgesite/config.py index da0c1fb..91865b9 100644 --- a/judgesite/config.py +++ b/judgesite/config.py @@ -3,6 +3,8 @@ from collections import namedtuple +import requests + Configure = namedtuple("Configure", [ 'testdata_path', 'tmp_path', @@ -18,20 +20,25 @@ 'access_key', 'api_url' ]) - +mysql_setting = requests.get( + 'http://etcc-server:8009/services/mysql-01/configures/production/').json()['data'] +rabbitmq_setting = requests.get( + 'http://etcc-server:8009/services/rabbitmq-01/configures/production/').json()['data'] +judge_site_setting = requests.get( + 'http://etcc-server:8009/services/judge-site/configures/default/').json()['data'] conf = Configure( testdata_path="", tmp_path="", - mysql_user="", - mysql_password="", - mysql_host="", - mysql_db_name="", - rmq_host="", - rmq_port=5672, - rmq_queue="task", - rmq_user="guest", - rmq_password="guest", - access_key="", - api_url="", + mysql_user=mysql_setting['USER'], + mysql_password=mysql_setting['PASSWORD'], + mysql_host=mysql_setting['HOST'], + mysql_db_name="fishteam_onlinejudge", + rmq_host=rabbitmq_setting['HOST'], + rmq_port=rabbitmq_setting['PORT'], + rmq_user=rabbitmq_setting['USER'], + rmq_password=rabbitmq_setting['PASSWORD'], + rmq_queue=judge_site_setting['rmq_queue'], + access_key=judge_site_setting['access_key'], + api_url=judge_site_setting['api_url'], ) diff --git a/requirements.txt b/requirements.txt index 2983194..0adcfec 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ MySQL-python==1.2.5 pika==0.9.14 requests==2.6.0 -SQLAlchemy==0.9.9 +SQLAlchemy==1.0.11 From 36456b3bf9e5fcbcefaca97dd14d4d7d76eb95b0 Mon Sep 17 00:00:00 2001 From: Comzyh Date: Sat, 9 Jan 2016 04:49:37 +0800 Subject: [PATCH 2/3] support SPJ --- judgesite/task.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/judgesite/task.py b/judgesite/task.py index a1c4679..b374d50 100644 --- a/judgesite/task.py +++ b/judgesite/task.py @@ -27,6 +27,7 @@ def __init__(self, message): self.testdata_id = str(task["testdata_id"]) self.time_limit = str(task["time_limit"]) self.memory_limit = str(task["memory_limit"]) + self.validator = str(task["validator"]) self.result = "" self.run_time = 0 @@ -37,6 +38,8 @@ def go(self): self._clean_files() try: + self._compile_spj_exec() + self._prepare_temp_dir() self._dump_code_to_file() @@ -53,7 +56,18 @@ def go(self): self._save_result() - self._clean_files() + # self._clean_files() + + def _compile_spj_exec(self): + if self.validator == 'Special Validator': + spj_exec_path = os.path.join( + conf.testdata_path, self.testdata_id, "SpecialJudge") + if not os.path.exists(spj_exec_path): + spj_code_file = os.path.join( + conf.testdata_path, self.testdata_id, "specialjudge.cpp") + commands = ["g++", spj_code_file, "-lm", + "-static", "-O2", "-w", '-o', spj_exec_path] + subprocess.call(commands) def _prepare_temp_dir(self): logging.info("Prepare temp dir") @@ -77,13 +91,18 @@ def _prepare_testdata_file(self): raise NoTestDataException shutil.copy(input_file, conf.tmp_path) shutil.copy(output_file, conf.tmp_path) + if self.validator == 'Special Validator': + spj_exec_path = os.path.join( + conf.testdata_path, self.testdata_id, "SpecialJudge") + shutil.copy(spj_exec_path, conf.tmp_path) def _run(self): logging.info("GO!GO!GO!") commands = ["sudo", "./Core", "-c", self.code_file, "-t", self.time_limit, "-m", self.memory_limit, "-d", conf.tmp_path] - + if self.validator == 'Special Validator': + commands += ["-s", "-S", "2"] # 2 = cpp subprocess.call(commands) def _read_result(self): From c5be9782ee84c5cae8c45613c815a2dfc0491e7c Mon Sep 17 00:00:00 2001 From: Comzyh Date: Sat, 9 Jan 2016 19:03:59 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20etcc=20=E5=9F=9F?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- judgesite/config.py | 6 +++--- judgesite/task.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/judgesite/config.py b/judgesite/config.py index 91865b9..15ff2ef 100644 --- a/judgesite/config.py +++ b/judgesite/config.py @@ -21,11 +21,11 @@ 'api_url' ]) mysql_setting = requests.get( - 'http://etcc-server:8009/services/mysql-01/configures/production/').json()['data'] + 'http://etcc.in.njoj.org:8009/services/mysql-01/configures/production/').json()['data'] rabbitmq_setting = requests.get( - 'http://etcc-server:8009/services/rabbitmq-01/configures/production/').json()['data'] + 'http://etcc.in.njoj.org:8009/services/rabbitmq-01/configures/production/').json()['data'] judge_site_setting = requests.get( - 'http://etcc-server:8009/services/judge-site/configures/default/').json()['data'] + 'http://etcc.in.njoj.org:8009/services/judge-site/configures/default/').json()['data'] conf = Configure( testdata_path="", diff --git a/judgesite/task.py b/judgesite/task.py index b374d50..8fcfdbb 100644 --- a/judgesite/task.py +++ b/judgesite/task.py @@ -56,7 +56,7 @@ def go(self): self._save_result() - # self._clean_files() + self._clean_files() def _compile_spj_exec(self): if self.validator == 'Special Validator':