testing directory

This commit is contained in:
Egor Matveev 2022-05-02 23:30:05 +03:00
parent ad0e4a641c
commit ad62672452
3 changed files with 3 additions and 23 deletions

View File

@ -1,10 +1,7 @@
from functools import cached_property
from os.path import exists
from shutil import rmtree
from subprocess import call
from django.contrib.auth.models import User
from django.db.models import JSONField
from django.db import models
from django.utils import timezone
@ -23,7 +20,7 @@ class Solution(models.Model):
result = models.TextField(default=CONSTS["in_queue_status"])
test = models.IntegerField(default=None, null=True, blank=True)
set = models.ForeignKey(Set, null=True, blank=True, on_delete=models.SET_NULL)
extras = JSONField(default=dict)
extras = models.JSONField(default=dict)
class Meta:
indexes = [
@ -46,11 +43,6 @@ class Solution(models.Model):
def language(self):
return languages[self.language_id]
def delete(self, using=None, keep_parents=False):
if exists(self.directory):
rmtree(self.directory)
super().delete(using=using, keep_parents=keep_parents)
@cached_property
def files(self):
data = []
@ -75,10 +67,6 @@ class Solution(models.Model):
data.sort(key=lambda x: x["filename"])
return data
@property
def directory(self):
return "solutions/" + str(self.id)
@property
def number_result(self):
if self.test is None:
@ -95,10 +83,6 @@ class Solution(models.Model):
return "info"
return "danger"
@property
def testing_directory(self):
return self.directory
@property
def volume_directory(self):
return "/sprint-data/worker/" + str(self.id)

View File

@ -22,7 +22,7 @@ class BaseTester:
def before_test(self):
files = [
file
for file in listdir(self.solution.testing_directory)
for file in listdir(self.path)
if file.endswith("." + self.solution.language.file_type)
]
code = self.solution.exec_command(
@ -40,7 +40,7 @@ class BaseTester:
)
if code != 0:
raise TestException("RE")
result = open(join(self.solution.testing_directory, "output.txt"), "r").read().strip().replace('\r\n', '\n')
result = open(join(self.path, "output.txt"), "r").read().strip().replace('\r\n', '\n')
print("got result", result)
if self.checker_code is not None:
print('using checker')

View File

@ -20,7 +20,3 @@ class Command(MessagingSupport):
print(e)
solution.result = "TE"
solution.save()
finally:
path = join("solutions", str(id))
if exists(path):
rmtree(path)