This commit is contained in:
Egor Matveev
2021-11-12 00:53:16 +03:00
parent a31d940429
commit cc95eb34ec
3 changed files with 7 additions and 6 deletions

View File

@@ -60,19 +60,19 @@ class BaseTester:
for file in SolutionFile.objects.filter(solution=self.solution):
dirs = file.path.split('/')
for i in range(len(dirs) - 1):
name = join("solution", '/'.join(dirs[:i + 1]))
name = join(str(self.solution.id), '/'.join(dirs[:i + 1]))
if not exists(name):
mkdir(name)
with open(join("solution", file.path), 'wb') as fs:
with open(join(str(self.solution.id), file.path), 'wb') as fs:
fs.write(get_bytes(file.fs_id))
self.solution.result = CONSTS["testing_status"]
self.solution.save()
docker_command = f"docker run --name solution_{self.solution.id} --volume=/usr/src/app/solution:/{self.working_directory} -t -d {self.solution.language.image}"
docker_command = f"docker run --name solution_{self.solution.id} --volume={self.solution.volume_directory}:/{self.working_directory} -t -d {self.solution.language.image}"
print(docker_command)
call(docker_command, shell=True)
print("Container created")
for file in ExtraFile.objects.filter(task=self.solution.task):
with open(join("solution", file.filename), 'wb') as fs:
with open(join(str(self.solution.id), file.filename), 'wb') as fs:
fs.write(get_bytes(file.fs_id))
print("Files copied")
try:
@@ -102,7 +102,7 @@ class BaseTester:
self.solution.result = "TE"
print(str(e))
self.solution.save()
# call(f"docker rm --force solution_{self.solution.id}", shell=True)
call(f"docker rm --force solution_{self.solution.id}", shell=True)
self.solution.user.userinfo.refresh_from_db()
if self.solution.user.userinfo.notification_solution_result:
bot.send_message(