From ad62672452d7f7021f59d4108d4202e5d5be7617 Mon Sep 17 00:00:00 2001 From: Egor Matveev Date: Mon, 2 May 2022 23:30:05 +0300 Subject: [PATCH] testing directory --- Main/models/solution.py | 18 +----------------- SprintLib/testers/BaseTester.py | 4 ++-- daemons/management/commands/receive.py | 4 ---- 3 files changed, 3 insertions(+), 23 deletions(-) diff --git a/Main/models/solution.py b/Main/models/solution.py index a51666a..e14421b 100644 --- a/Main/models/solution.py +++ b/Main/models/solution.py @@ -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) diff --git a/SprintLib/testers/BaseTester.py b/SprintLib/testers/BaseTester.py index bc2d0fb..e038e5f 100644 --- a/SprintLib/testers/BaseTester.py +++ b/SprintLib/testers/BaseTester.py @@ -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') diff --git a/daemons/management/commands/receive.py b/daemons/management/commands/receive.py index c09ca11..bea0a8d 100644 --- a/daemons/management/commands/receive.py +++ b/daemons/management/commands/receive.py @@ -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)