codestyle

This commit is contained in:
Egor Matveev
2021-12-02 18:24:51 +03:00
parent 255a364c34
commit d2d427fd6e
25 changed files with 168 additions and 378 deletions

View File

@@ -50,7 +50,7 @@ languages = [
file_type="java",
logo_url="https://upload.wikimedia.org/wikipedia/ru/thumb/3/39/Java_logo.svg/1200px-Java_logo.svg.png",
image="openjdk",
highlight="java"
highlight="java",
),
Language(
id=4,
@@ -59,6 +59,6 @@ languages = [
file_type="cs",
logo_url="https://cdn.worldvectorlogo.com/logos/c--4.svg",
image="mono",
highlight="csharp"
)
highlight="csharp",
),
]

View File

@@ -9,4 +9,8 @@ def send_testing(solution_id):
) as connection:
channel = connection.channel()
channel.queue_declare(queue="test")
channel.basic_publish(exchange="", routing_key="test", body=bytes(str(solution_id), encoding='utf-8'))
channel.basic_publish(
exchange="",
routing_key="test",
body=bytes(str(solution_id), encoding="utf-8"),
)

View File

@@ -63,12 +63,16 @@ class BaseTester:
mkdir("solutions")
mkdir("solutions/" + str(self.solution.id))
for file in SolutionFile.objects.filter(solution=self.solution):
dirs = file.path.split('/')
dirs = file.path.split("/")
for i in range(len(dirs) - 1):
name = join(str("solutions/" + 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("solutions/" + 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()
@@ -77,7 +81,9 @@ class BaseTester:
call(docker_command, shell=True)
print("Container created")
for file in ExtraFile.objects.filter(task=self.solution.task):
with open(join("solutions/" + 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:

View File

@@ -7,13 +7,17 @@ class JavaTester(BaseTester):
_executable = None
def before_test(self):
files = [file for file in listdir(self.solution.testing_directory) if file.endswith('.java')]
files = [
file
for file in listdir(self.solution.testing_directory)
if file.endswith(".java")
]
code = self.solution.exec_command(f"javac {' '.join(files)}")
if code != 0:
raise TestException('CE')
raise TestException("CE")
for file in listdir(self.solution.testing_directory):
if file.endswith('.class'):
self._executable = file.rstrip('.class')
if file.endswith(".class"):
self._executable = file.rstrip(".class")
break
if self._executable is None:
raise TestException("TE")

View File

@@ -5,10 +5,16 @@ from SprintLib.testers.BaseTester import BaseTester, TestException
class KotlinTester(BaseTester):
def before_test(self):
files = [file for file in listdir(self.solution.testing_directory) if file.endswith('.kt')]
code = self.solution.exec_command(f'kotlinc {" ".join(files)} -include-runtime -d solution.jar')
files = [
file
for file in listdir(self.solution.testing_directory)
if file.endswith(".kt")
]
code = self.solution.exec_command(
f'kotlinc {" ".join(files)} -include-runtime -d solution.jar'
)
if code != 0:
raise TestException('CE')
raise TestException("CE")
@property
def command(self):

View File

@@ -6,7 +6,7 @@ from Sprint import settings
def write_bytes(data):
url = settings.FS_HOST + ":" + str(settings.FS_PORT) + "/upload_file"
print(url)
return post(url, data=data).json()['id']
return post(url, data=data).json()["id"]
def get_bytes(num):