Files
kefu/deploy/loading-performance-20260917/finish_protocol_timing_ui.py
T
2026-09-21 10:34:06 +08:00

17 lines
1.1 KiB
Python

from pathlib import Path
import os
path=Path(r'C:\wechat_rpa\wechat_gui_qt.py')
text=path.read_text(encoding='utf-8')
text=text.replace('正在识别企业微信实际安装位置、当前账号及聊天数据目录;首次初始化可能需要约 60 秒,不发送消息…', '正在核对当前账号、客户端和消息库;仅缺少可用密钥时进行初始化,不发送消息…')
old=''' self.append_log("[协议检测] " + str(self._protocol_probe.get("message") or "已完成"),
"ok" if self._protocol_probe["canSend"] else "warn")'''
new=''' elapsed = (self._protocol_report.get("timingsMs") or {}).get("total")
elapsed_label = f"(耗时 {elapsed / 1000:.2f} 秒)" if isinstance(elapsed, (int, float)) else ""
self.append_log("[协议检测] " + str(self._protocol_probe.get("message") or "已完成") + elapsed_label,
"ok" if self._protocol_probe["canSend"] else "warn")'''
assert old in text
text=text.replace(old,new,1)
compile(text,str(path),'exec')
temp=path.with_suffix('.performance-tmp');temp.write_text(text,encoding='utf-8');os.replace(temp,path)