-
Notifications
You must be signed in to change notification settings - Fork 0
/
executor.py
36 lines (33 loc) · 1.16 KB
/
executor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from __future__ import print_function
from tools.testing_exceptions import *
from tools.preparator import *
class Executor:
def __init__(self, language, task_id, source, path):
self.task = get_task(language, task_id)
self.path = path
self.task.source = source
def execute(self, do_cleanup = True):
task = self.task
path = self.path
try:
prepare_directory(path)
task.create_files(path)
task.compile(path)
task.test(path)
except CompilationLimitExceeded as exception:
result = ("failed", "Compilation time limit exceeded.")
except CompilationError as exception:
result = ("failed", "Compilation error: " + unicode(exception))
except Crash as exception:
result = ("failed", "Crash: " + unicode(exception))
except TimeLimitExceeded as exception:
result = ("failed", unicode(exception))
except WrongAnswer as exception:
result = ("failed", "Wrong Answer: " + unicode(exception))
except TesterFailed as exception:
result = ("failed", "Out tester failed on: " + unicode(exception))
else:
result = ("accepted", None)
if do_cleanup:
cleanup(path)
return result