Skip to content

Commit

Permalink
Merge pull request #14 from NJUST-FishTeam/dev_comzyh
Browse files Browse the repository at this point in the history
add NoTestDataError
  • Loading branch information
maemual committed Jun 14, 2015
2 parents b105a11 + 0185886 commit 91c277b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,6 @@ Core
*.in
*.out
*.log
testdata/
tmp/
core_log.txt
34 changes: 26 additions & 8 deletions judgesite/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
from models import save_result


class NoTestDataException(Exception):
pass


class JudgeTask(object):

def __init__(self, message):
Expand All @@ -24,18 +28,28 @@ def __init__(self, message):
self.time_limit = str(task["time_limit"])
self.memory_limit = str(task["memory_limit"])

self.result = ""
self.run_time = 0
self.run_memory = 0
self.others = ""

def go(self):
self._clean_files()

self._prepare_temp_dir()

self._dump_code_to_file()
try:
self._prepare_temp_dir()

self._prepare_testdata_file()
self._dump_code_to_file()

self._run()
self._prepare_testdata_file()
except NoTestDataException, e:
self.result = 'NoTestDataError'
except Exception, e:
raise e
else:
self._run()

self._read_result()
self._read_result()

self._save_result()

Expand All @@ -55,8 +69,12 @@ def _dump_code_to_file(self):

def _prepare_testdata_file(self):
logging.info("Prepare testdata")
input_file = os.path.join(conf.testdata_path, self.testdata_id, "in.in")
output_file = os.path.join(conf.testdata_path, self.testdata_id, "out.out")
input_file = os.path.join(
conf.testdata_path, self.testdata_id, "in.in")
output_file = os.path.join(
conf.testdata_path, self.testdata_id, "out.out")
if not os.path.exists(input_file) or not os.path.exists(output_file):
raise NoTestDataException
shutil.copy(input_file, conf.tmp_path)
shutil.copy(output_file, conf.tmp_path)

Expand Down

0 comments on commit 91c277b

Please sign in to comment.