checkers
This commit is contained in:
@@ -14,14 +14,14 @@ from testers import *
|
||||
host = "http://dev.sprinthub.ru/"
|
||||
|
||||
|
||||
def process_solution(path, data, language_id, solution_id, timeout):
|
||||
def process_solution(path, data, language_id, solution_id, timeout, token, host):
|
||||
with open(join(path, "package.zip"), 'wb') as fs:
|
||||
fs.write(data)
|
||||
with ZipFile(join(path, "package.zip"), 'r') as zip_ref:
|
||||
zip_ref.extractall(path)
|
||||
language = languages[language_id]
|
||||
try:
|
||||
result = eval(language.work_name + "Tester")(path, solution_id, language_id, timeout).execute()
|
||||
result = eval(language.work_name + "Tester")(path, solution_id, language_id, timeout, token, host).execute()
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
result = "TE"
|
||||
@@ -61,6 +61,8 @@ def main():
|
||||
int(data.headers['language_id']),
|
||||
int(data.headers['solution_id']),
|
||||
int(data.headers['timeout']),
|
||||
dynamic_token,
|
||||
host
|
||||
)
|
||||
get(f"{host}checker/set_result", params={
|
||||
"token": dynamic_token,
|
||||
|
@@ -3,6 +3,9 @@ from os.path import join, exists
|
||||
from subprocess import call, TimeoutExpired
|
||||
|
||||
from language import *
|
||||
from requests import get
|
||||
|
||||
from SprintLib.language import languages
|
||||
|
||||
|
||||
class TestException(Exception):
|
||||
@@ -78,11 +81,13 @@ class BaseTester:
|
||||
def language(self):
|
||||
return languages[self.language_id]
|
||||
|
||||
def __init__(self, path, solution_id, language_id, timeout):
|
||||
def __init__(self, path, solution_id, language_id, timeout, token, host):
|
||||
self.solution_id = solution_id
|
||||
self._path = path
|
||||
self.language_id = language_id
|
||||
self.timeout = timeout
|
||||
self.token = token
|
||||
self.host = host
|
||||
|
||||
def execute(self):
|
||||
docker_command = f"docker run --name solution --volume={self.path}:/{self.working_directory} -t -d {self.language.image}"
|
||||
@@ -101,6 +106,7 @@ class BaseTester:
|
||||
if not file.endswith(".a") and exists(join(self.path, file + '.a')):
|
||||
self.predicted = open(join(self.path, file + '.a'), 'r').read().strip().replace('\r\n', '\n')
|
||||
print('predicted:', self.predicted)
|
||||
get(f"{self.host}checker/current_test", params={"token": self.token, 'test': file})
|
||||
self.test(file)
|
||||
self.after_test()
|
||||
result = "OK"
|
||||
|
Reference in New Issue
Block a user