Commit 8943dba6 authored by dwoiwode's avatar dwoiwode
Browse files

Adjust to PEP8

parent a872c887
......@@ -55,7 +55,7 @@ class Config:
raise RuntimeError("Git is not configured correctly")
self._git = pterClasses.GitHelper(self.GIT_REPO, self.GIT_REPO_PATH)
self._git.forcePull()
self._git.force_pull()
self._git.config(self.GIT_EMAIL, self.GIT_NAME)
self._git.update()
return self._git
This diff is collapsed.
......@@ -13,67 +13,72 @@ class ProtokollGUI(tk.Tk):
self.rootPad = pter.PadCollection(pter.CodiMD(self.opt.PAD_COLLECTION_URL))
self.folders = dict()
self.folderIndex = 0
self.folders = self.rootPad.getPads()
self.currentPads = list()
self.folder_index = 0
self.folders = self.rootPad.get_pads()
self.current_pads = list()
self.topRow = tk.Frame(self)
self.topRow.pack(fill=tk.X, expand=True)
self.folderLabel = tk.Label(self.topRow)
self.leftButton = tk.Button(self.topRow, text="<", state=tk.DISABLED, command=self.updateFolderIndex(-1))
self.rightButton = tk.Button(self.topRow, text=">", command=self.updateFolderIndex(1))
self.top_row = tk.Frame(self)
self.top_row.pack(fill=tk.X, expand=True)
self.folder_label = tk.Label(self.top_row)
self.button_left = tk.Button(self.top_row, text="<", state=tk.DISABLED, command=self.update_folder_index(-1))
self.button_right = tk.Button(self.top_row, text=">", command=self.update_folder_index(1))
self.leftButton.pack(side=tk.LEFT)
self.folderLabel.pack(side=tk.LEFT, fill=tk.X, expand=True)
self.rightButton.pack(side=tk.LEFT)
self.button_left.pack(side=tk.LEFT)
self.folder_label.pack(side=tk.LEFT, fill=tk.X, expand=True)
self.button_right.pack(side=tk.LEFT)
self.padFrame = tk.Frame(self)
self.padFrame.pack()
self.pad_frame = tk.Frame(self)
self.pad_frame.pack()
self.updatePadFrame()
self.update_pad_frame()
def updateFolderIndex(self, i):
@wraps(self.updateFolderIndex)
def update_folder_index(self, i):
@wraps(self.update_folder_index)
def wrapper(*args, **kwargs):
self.folderIndex = (self.folderIndex + i) % len(self.folders)
self.updatePadFrame()
self.folder_index = (self.folder_index + i) % len(self.folders)
self.update_pad_frame()
return wrapper
def updatePadFrame(self):
folderName = list(self.folders.keys())[self.folderIndex]
self.folderLabel.configure(text=folderName)
self.currentPads = [p for p in self.folders[folderName] if isinstance(p, pter.ProtocolPad)]
for i, pad in enumerate(self.currentPads):
def update_pad_frame(self):
folderName = list(self.folders.keys())[self.folder_index]
self.folder_label.configure(text=folderName)
self.current_pads = [p for p in self.folders[folderName] if isinstance(p, pter.ProtocolPad)]
for i, pad in enumerate(self.current_pads):
assert isinstance(pad, pter.ProtocolPad)
approvedState = tk.NORMAL if pad.isApproved else tk.DISABLED
color = "green" if pad.isApproved else "red"
tk.Label(self.padFrame, text=pad.date.strftime("%Y-%m-%d"), anchor=tk.W).grid(row=i, column=0) # Date
tk.Label(self.padFrame, text=pad.source.url, anchor=tk.W).grid(row=i, column=1, sticky=tk.W) # URL
approved_state = tk.NORMAL if pad.is_approved else tk.DISABLED
color = "green" if pad.is_approved else "red"
tk.Label(self.pad_frame, text=pad.date.strftime("%Y-%m-%d"), anchor=tk.W).grid(row=i, column=0) # Date
tk.Label(self.pad_frame, text=pad.source.url, anchor=tk.W).grid(row=i, column=1, sticky=tk.W) # URL
# Button Download
btnDownload = tk.Button(self.padFrame, text="Download", command=pad.download)
btnDownload.grid(row=i, column=2)
btn_download = tk.Button(self.pad_frame, text="Download",
command=pad.download)
btn_download.grid(row=i, column=2)
# Button Compile
btnCompile = tk.Button(self.padFrame, text="Compile", command=pad.compile)
btnCompile.grid(row=i, column=3)
btn_compile = tk.Button(self.pad_frame, text="Compile",
command=pad.compile)
btn_compile.grid(row=i, column=3)
# Button Mail FR
btnMailFR = tk.Button(self.padFrame, text="Vorläufige FR-Mail", command=pad.sendMailAsPreliminary)
btnMailFR.grid(row=i, column=4)
btn_mail_fr = tk.Button(self.pad_frame, text="Vorläufige FR-Mail",
command=pad.send_mail_as_preliminary)
btn_mail_fr.grid(row=i, column=4)
# Button Mail FR-Info
btnMailFRInfo = tk.Button(self.padFrame, text="FR-Info Mail", state=approvedState, bg=color,
command=pad.sendMailAsApproved)
btnMailFRInfo.grid(row=i, column=5)
btn_mail_fr_info = tk.Button(self.pad_frame, text="FR-Info Mail", state=approved_state, bg=color,
command=pad.send_mail_as_approved)
btn_mail_fr_info.grid(row=i, column=5)
# Button Website
btnWebsite = tk.Button(self.padFrame, text="Approved Website", state=approvedState, bg=color, command=pad.uploadToGrav)
btnWebsite.grid(row=i, column=6)
btn_website = tk.Button(self.pad_frame, text="Approved Website", state=approved_state, bg=color,
command=pad.upload_to_grav)
btn_website.grid(row=i, column=6)
# Button Cloud
btnCloud = tk.Button(self.padFrame, text="Approved Cloud", state=approvedState, bg=color, command=pad.uploadToCloud)
btnCloud.grid(row=i, column=7)
btn_cloud = tk.Button(self.pad_frame, text="Approved Cloud", state=approved_state, bg=color,
command=pad.upload_to_cloud)
btn_cloud.grid(row=i, column=7)
if __name__ == '__main__':
......
......@@ -17,7 +17,7 @@ class Gremium:
fullName: str
template: str
def fullTemplate(self):
def full_template(self):
from linkToPDF2 import opt
return str(Path(os.path.join(opt.TEMPLATE_FOLDER, self.template)).absolute())
......@@ -46,10 +46,10 @@ class MailParticipant:
return MailParticipant("fr@finf.uni-hannover.de", "Fachrat Informatik")
def sendFRMail(text: str, subject: str, sender: MailParticipant, receivers: List[MailParticipant],
attachment: "BasePad" = None, *_, ldapPassword=None):
if ldapPassword is None:
raise ValueError("Require ldapPassword")
def send_fr_mail(text: str, subject: str, sender: MailParticipant, receivers: List[MailParticipant],
attachment: "BasePad" = None, *_, ldap_password=None):
if ldap_password is None:
raise ValueError("Require LDAP password")
mail = MIMEMultipart()
mail['Message-Id'] = f"{hashlib.sha256(text.encode('utf-8')).hexdigest()}@pter.finf.uni-hannover.de"
mail['Content-transfer-encoding'] = '8bit'
......@@ -62,17 +62,17 @@ def sendFRMail(text: str, subject: str, sender: MailParticipant, receivers: List
mail.attach(msg)
if attachment is not None:
payload = MIMEBase('application', 'octet-stream')
with open(str(attachment.compiledPath), "rb") as d:
with open(str(attachment.compiled_path), "rb") as d:
payload.set_payload(d.read())
encoders.encode_base64(payload)
payload.add_header('Content-Disposition',
f"attachment; filename=\"{attachment.displayName}.pdf\"")
f"attachment; filename=\"{attachment.display_name}.pdf\"")
mail.attach(payload)
try:
server = smtplib.SMTP("mail.finf.uni-hannover.de", 587)
server.starttls()
server.login(sender.mail, ldapPassword)
server.login(sender.mail, ldap_password)
server.sendmail(
sender.mail, [r.mail for r in receivers], mail.as_string())
server.quit()
......@@ -100,7 +100,7 @@ class GitHelper:
cmd = f'git clone {self.repository} {self.repository_path}'
return os.system(cmd)
def forcePull(self):
def force_pull(self):
cmd = f'git -C {self.repository_path} fetch origin master'
ret = os.system(cmd)
if ret != 0:
......@@ -110,7 +110,7 @@ class GitHelper:
def update(self):
if os.path.exists(os.path.join(self.repository_path, "/.git")):
return self.forcePull()
return self.force_pull()
else:
return self.clone()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment