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

@@ -36,23 +36,20 @@ class Solution(models.Model):
text = file.text
except:
continue
entity = {
'filename': file.path,
'text': text
}
end = file.path.split('.')[-1]
entity = {"filename": file.path, "text": text}
end = file.path.split(".")[-1]
language = None
for l in languages:
if l.file_type == end:
language = l
break
if language is None:
highlight = 'nohighlight'
highlight = "nohighlight"
else:
highlight = 'language-' + language.highlight
entity['highlight'] = highlight
highlight = "language-" + language.highlight
entity["highlight"] = highlight
data.append(entity)
data.sort(key=lambda x: x['filename'])
data.sort(key=lambda x: x["filename"])
return data
@property
@@ -67,5 +64,9 @@ class Solution(models.Model):
def volume_directory(self):
return "/sprint-data/worker/" + str(self.id)
def exec_command(self, command, working_directory='app', timeout=None):
return call(f'docker exec -i solution_{self.id} sh -c "cd {working_directory} && {command}"', shell=True, timeout=timeout)
def exec_command(self, command, working_directory="app", timeout=None):
return call(
f'docker exec -i solution_{self.id} sh -c "cd {working_directory} && {command}"',
shell=True,
timeout=timeout,
)