diff --git a/_build/commit_final.py b/_build/commit_final.py new file mode 100644 index 0000000..c646bee --- /dev/null +++ b/_build/commit_final.py @@ -0,0 +1,68 @@ +# -*- coding: utf-8 -*- +r'''提交最后的两个修复。''' +from __future__ import annotations + +import os +import subprocess +import sys +from pathlib import Path + +ROOT = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote") +GIT = r"C:\Program Files\Git\bin\git.exe" + +MSG = """修 --quiet 卸载日志的两个问题(静态检查抓出来的) + +1. run_agent.py 用了 Path 但没导入 + 静态检查报 "undefined name 'Path'"。它被 try/except 吞了, + 所以卸载功能本身没坏,但**日志从来没写成过** —— + 属于"看着没事、其实功能是死的",最容易被漏掉的那种。 + +2. 日志写到刚被删掉的数据目录里 + 原来是 Path(data_dir())/"uninstall.log",但 do_uninstall() + 会把整个数据目录删掉,写完等于白写。 + 改到 %TEMP%\\ykxmz-uninstall.log。 + +现在日志能正常落盘,内容长这样: + 开始卸载 ykxmz + 已停止其它 ykxmz.exe 实例(本进程 15572 除外) + 没有开机自启项 + 已删除数据目录 ... + 程序目录交给安装包的卸载器删除 + 卸载完成。 + +最终全量套件(33 个阶段): + 30 PASS + 3 SKIP(锁屏) + 0 FAIL + 新增的「安装包完整周期」PASS +""" + + +def main() -> int: + subprocess.run([GIT, "add", "-A"], cwd=str(ROOT), check=False) + msg_file = ROOT / "_build" / "_cmsg5.txt" + msg_file.write_bytes(MSG.encode("utf-8")) + r = subprocess.run([GIT, "commit", "-q", "-F", str(msg_file)], + cwd=str(ROOT), capture_output=True, text=True, + encoding="utf-8", errors="replace") + msg_file.unlink(missing_ok=True) + print(" commit exit=%s" % r.returncode) + show = subprocess.run([GIT, "log", "--oneline", "-1"], cwd=str(ROOT), + capture_output=True, text=True, encoding="utf-8", + errors="replace") + print(" " + (show.stdout or "").strip()) + env = dict(os.environ) + env["GIT_SSH_COMMAND"] = r'"C:\Program Files\Git\usr\bin\ssh.exe"' + push = subprocess.run([GIT, "push", "origin", "main"], cwd=str(ROOT), + capture_output=True, text=True, encoding="utf-8", + errors="replace", env=env) + for line in (push.stderr or push.stdout or "").strip().splitlines()[-2:]: + print(" " + line) + status = subprocess.run([GIT, "status", "--short"], cwd=str(ROOT), + capture_output=True, text=True, encoding="utf-8", + errors="replace") + print(" 工作区: %s" % ("干净 ✓" if not (status.stdout or "").strip() + else (status.stdout or "").strip()[:160])) + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/windows/run_agent.py b/windows/run_agent.py index b2af0e1..b7d5208 100644 --- a/windows/run_agent.py +++ b/windows/run_agent.py @@ -36,6 +36,7 @@ from __future__ import annotations import argparse import os import sys +from pathlib import Path from lanremote import APP_NAME, __version__ from lanremote.config import Store, app_dir, data_dir @@ -135,11 +136,14 @@ def cli_uninstall(keep_dir: bool = False, quiet: bool = False) -> int: code = 0 if quiet: - # 没有控制台,把结果落到文件,排查时能看 + # 没有控制台,把结果落到文件,排查时能看。 + # + # ⚠ 别写进数据目录!do_uninstall() 会把它整个删掉, + # 写到那里等于白写(实测:日志文件从来没出现过)。 + # 放 %TEMP% 最稳妥。 try: - from lanremote.config import data_dir - log = Path(str(data_dir())) / "uninstall.log" - log.parent.mkdir(parents=True, exist_ok=True) + import tempfile + log = Path(tempfile.gettempdir()) / "ykxmz-uninstall.log" log.write_text(report, encoding="utf-8") except Exception: # noqa: BLE001 pass