排程管理及排程记录查看功能
This commit is contained in:
1 parent
3b31867319
commit
08776feef2
28 files changed
+3040
-8
No files matched your search
@@ -0,0 +1,37 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import smtplib
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
|
||||
|
||||
def send_schedule_mail(*, smtp_host: str, smtp_port: int, smtp_user: str, smtp_password: str, use_tls: bool, from_addr: str, to_addrs: list[str], subject: str, html_body: str) -> None:
|
||||
if not to_addrs:
|
||||
return
|
||||
msg = MIMEMultipart('alternative')
|
||||
msg['Subject'] = subject
|
||||
msg['From'] = from_addr
|
||||
msg['To'] = ', '.join(to_addrs)
|
||||
msg.attach(MIMEText(html_body, 'html', 'utf-8'))
|
||||
|
||||
with smtplib.SMTP(smtp_host, smtp_port, timeout=20) as server:
|
||||
if use_tls:
|
||||
server.starttls()
|
||||
if smtp_user:
|
||||
server.login(smtp_user, smtp_password)
|
||||
server.sendmail(from_addr, to_addrs, msg.as_string())
|
||||
|
||||
|
||||
def build_schedule_mail_html(*, schedule_name: str, run_no: str, status: str, total: int, success: int, failed: int) -> str:
|
||||
return (
|
||||
"<html><body>"
|
||||
"<h3>排程执行结果</h3>"
|
||||
"<table border='1' cellspacing='0' cellpadding='6'>"
|
||||
f"<tr><th>排程</th><td>{schedule_name}</td></tr>"
|
||||
f"<tr><th>执行单号</th><td>{run_no}</td></tr>"
|
||||
f"<tr><th>状态</th><td>{status}</td></tr>"
|
||||
f"<tr><th>总数</th><td>{total}</td></tr>"
|
||||
f"<tr><th>成功</th><td>{success}</td></tr>"
|
||||
f"<tr><th>失败</th><td>{failed}</td></tr>"
|
||||
"</table></body></html>"
|
||||
)
|
||||
Reference in new issue
Block a user