testing directory
This commit is contained in:
parent
ad0e4a641c
commit
ad62672452
@ -1,10 +1,7 @@
|
|||||||
from functools import cached_property
|
from functools import cached_property
|
||||||
from os.path import exists
|
|
||||||
from shutil import rmtree
|
|
||||||
from subprocess import call
|
from subprocess import call
|
||||||
|
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.db.models import JSONField
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
@ -23,7 +20,7 @@ class Solution(models.Model):
|
|||||||
result = models.TextField(default=CONSTS["in_queue_status"])
|
result = models.TextField(default=CONSTS["in_queue_status"])
|
||||||
test = models.IntegerField(default=None, null=True, blank=True)
|
test = models.IntegerField(default=None, null=True, blank=True)
|
||||||
set = models.ForeignKey(Set, null=True, blank=True, on_delete=models.SET_NULL)
|
set = models.ForeignKey(Set, null=True, blank=True, on_delete=models.SET_NULL)
|
||||||
extras = JSONField(default=dict)
|
extras = models.JSONField(default=dict)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
indexes = [
|
indexes = [
|
||||||
@ -46,11 +43,6 @@ class Solution(models.Model):
|
|||||||
def language(self):
|
def language(self):
|
||||||
return languages[self.language_id]
|
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
|
@cached_property
|
||||||
def files(self):
|
def files(self):
|
||||||
data = []
|
data = []
|
||||||
@ -75,10 +67,6 @@ class Solution(models.Model):
|
|||||||
data.sort(key=lambda x: x["filename"])
|
data.sort(key=lambda x: x["filename"])
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@property
|
|
||||||
def directory(self):
|
|
||||||
return "solutions/" + str(self.id)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def number_result(self):
|
def number_result(self):
|
||||||
if self.test is None:
|
if self.test is None:
|
||||||
@ -95,10 +83,6 @@ class Solution(models.Model):
|
|||||||
return "info"
|
return "info"
|
||||||
return "danger"
|
return "danger"
|
||||||
|
|
||||||
@property
|
|
||||||
def testing_directory(self):
|
|
||||||
return self.directory
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def volume_directory(self):
|
def volume_directory(self):
|
||||||
return "/sprint-data/worker/" + str(self.id)
|
return "/sprint-data/worker/" + str(self.id)
|
||||||
|
@ -22,7 +22,7 @@ class BaseTester:
|
|||||||
def before_test(self):
|
def before_test(self):
|
||||||
files = [
|
files = [
|
||||||
file
|
file
|
||||||
for file in listdir(self.solution.testing_directory)
|
for file in listdir(self.path)
|
||||||
if file.endswith("." + self.solution.language.file_type)
|
if file.endswith("." + self.solution.language.file_type)
|
||||||
]
|
]
|
||||||
code = self.solution.exec_command(
|
code = self.solution.exec_command(
|
||||||
@ -40,7 +40,7 @@ class BaseTester:
|
|||||||
)
|
)
|
||||||
if code != 0:
|
if code != 0:
|
||||||
raise TestException("RE")
|
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)
|
print("got result", result)
|
||||||
if self.checker_code is not None:
|
if self.checker_code is not None:
|
||||||
print('using checker')
|
print('using checker')
|
||||||
|
@ -20,7 +20,3 @@ class Command(MessagingSupport):
|
|||||||
print(e)
|
print(e)
|
||||||
solution.result = "TE"
|
solution.result = "TE"
|
||||||
solution.save()
|
solution.save()
|
||||||
finally:
|
|
||||||
path = join("solutions", str(id))
|
|
||||||
if exists(path):
|
|
||||||
rmtree(path)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user