This commit is contained in:
Egor Matveev 2021-11-13 18:15:37 +03:00
parent 8b772f25bb
commit cc3d9b409f

View File

@ -1,6 +1,5 @@
from os import listdir, mkdir
from os.path import join, exists
from shutil import copyfile, rmtree
from subprocess import call, TimeoutExpired
from Main.management.commands.bot import bot
@ -62,10 +61,10 @@ class BaseTester:
for file in SolutionFile.objects.filter(solution=self.solution):
dirs = file.path.split('/')
for i in range(len(dirs) - 1):
name = join(str(self.solution.id), '/'.join(dirs[:i + 1]))
name = join(str("solutions/" + self.solution.id), '/'.join(dirs[:i + 1]))
if not exists(name):
mkdir(name)
with open(join(str(self.solution.id), file.path), 'wb') as fs:
with open(join("solutions/" + 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()
@ -74,7 +73,7 @@ class BaseTester:
call(docker_command, shell=True)
print("Container created")
for file in ExtraFile.objects.filter(task=self.solution.task):
with open(join(str(self.solution.id), file.filename), 'wb') as fs:
with open(join("solutions/" + str(self.solution.id), file.filename), 'wb') as fs:
fs.write(get_bytes(file.fs_id))
print("Files copied")
try: