Mail from mailbox

Closes #6
This commit is contained in:
Matej Focko 2019-11-30 22:47:08 +01:00
parent 4437e1a058
commit a79b3f4319
3 changed files with 18 additions and 11 deletions

View file

@ -14,7 +14,7 @@ from utils import run_cmd
class MergeRequests(BaseGitCommand):
@staticmethod
def get_files(submission: Submission) -> None:
files = f"{{master-naostro/LoadTest/{submission.homework}.py,teacher_email}}"
files = f"master-naostro/LoadTest/{submission.homework}.py"
if run_cmd("rsync", "-avzP", f"aisa:{submission.path}/{files}", "./")[0] != 0:
exit(1)
@ -25,14 +25,6 @@ class MergeRequests(BaseGitCommand):
with open("flake.log", "w") as f:
print(process.stdout, file=f)
@staticmethod
def get_mail() -> None:
with open("teacher_email") as file:
contents = file.read()
match = re.search(r"<pre>((.*\s+)+)<\/pre>", contents)
return match.group(1) if match else contents
def exec(self, submission: Submission) -> None:
self.get_files(submission)
self.call_flake(submission)
@ -45,7 +37,7 @@ class MergeRequests(BaseGitCommand):
source_branch=submission.branch,
target_branch="master",
title=f"[{submission.branch}] {submission.login}",
description=f"```\n{self.get_mail()}\n```",
description=f"```\n{submission.get_mail()}\n```",
labels=submission.homework,
remove_source_branch="true",
assignee_ids=["1772"],

View file

@ -64,7 +64,15 @@ class Parser:
points = Parser.parse_points(mail)
submissions.append(
Submission(uco, login, path, points, hw_tag, self.correction)
Submission(
uco,
login,
path,
points,
hw_tag,
self.correction,
mail.get_payload(),
)
)
submissions[-1].set_late_tag(self.deadline)

View file

@ -2,6 +2,7 @@
import datetime
import re
from typing import Dict, List
@ -14,6 +15,7 @@ class Submission:
points: float,
homework: str,
correction: bool,
mail: str,
) -> None:
self.uco = uco
self.login = login
@ -21,6 +23,7 @@ class Submission:
self.points = points
self.homework = homework
self.correction = correction
self.mail = mail
self.submitted_at = None
self.submitted_before_deadline = None
@ -38,6 +41,10 @@ class Submission:
if not self.submitted_before_deadline:
self.flag = "LATE"
def get_mail(self) -> str:
match = re.search(r"<pre>((.*\s+)+)<\/pre>", self.mail)
return match.group(1) if match else self.mail
def print_submissions(all_submissions: Dict[str, List[Submission]]) -> None:
header = (