support python36

This commit is contained in:
Your Name
2026-07-08 13:00:06 +08:00
parent 5250c2960c
commit da2fd92f07
5 changed files with 6 additions and 6 deletions
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -1,3 +1,4 @@
from typing import List, Dict, Tuple, Set, Any, Optional, Union
#!/usr/bin/env python3
"""
Palladium Z1 Monitor — LD逻辑板使用监控系统
@@ -10,7 +11,6 @@ Palladium Z1 Monitor — LD逻辑板使用监控系统
2. API 推送 — 在 Palladium 主机运行 collect.py 远程推送
"""
from __future__ import annotations # PEP 563: 兼容 Python 3.7+ (避免 PEP 585 泛型语法)
import os
import re
Binary file not shown.
+5 -5
View File
@@ -1,3 +1,4 @@
from typing import List, Dict, Tuple, Set, Any, Optional, Union
"""
mailer.py — Palladium Z1 每日报告邮件发送
@@ -5,7 +6,6 @@ mailer.py — Palladium Z1 每日报告邮件发送
所有配置都从环境变量读 (生产建议用 systemd EnvironmentFile 或 .env)。
"""
from __future__ import annotations # PEP 563: 让所有 type hint 变字符串, 兼容 Python 3.7+
import os
import smtplib
@@ -60,7 +60,7 @@ def get_config() -> dict:
}
def config_errors(cfg: dict) -> list[str]:
def config_errors(cfg: dict) -> List[str]:
"""检查配置是否完整可发送。返回缺失/错误项的列表 (空=OK)。"""
errs = []
if not cfg["enabled"]:
@@ -416,7 +416,7 @@ def _render_html(data: dict, base_url: str) -> str:
# ═══════════════════════════════════════════════════════════════════════════
# 发送
# ═══════════════════════════════════════════════════════════════════════════
def render_report(data: dict, cfg: dict) -> tuple[str, str, str]:
def render_report(data: dict, cfg: dict) -> Tuple[str, str, str]:
"""返回 (subject, html, text)。"""
latest = data["latest"]
if latest:
@@ -430,7 +430,7 @@ def render_report(data: dict, cfg: dict) -> tuple[str, str, str]:
return subject, html, text
def _send_smtp(cfg: dict, subject: str, html: str, text: str) -> tuple[bool, str]:
def _send_smtp(cfg: dict, subject: str, html: str, text: str) -> Tuple[bool, str]:
"""实际 SMTP 发送, 返回 (ok, error_msg)。"""
msg = MIMEMultipart("alternative")
msg["Subject"] = subject
@@ -469,7 +469,7 @@ def _send_smtp(cfg: dict, subject: str, html: str, text: str) -> tuple[bool, str
return (False, f"{type(e).__name__}: {e}")
def send_report(cfg: dict | None = None) -> dict:
def send_report(cfg: Optional[Dict] = None) -> dict:
"""
收集数据 → 渲染 → 发送。
返回: {"ok": bool, "subject": str, "recipients": [...], "error": str, "preview_text": str}