# -*- coding: utf-8 -*- r"""服务器端打包时带上 favicon.ico。 package_remote.py 原来只收 relay 目录下的 .py / .sh, favicon.ico 会被漏掉 —— 结果装到新设备上管理页又没图标了。 """ from __future__ import annotations import ast import sys from pathlib import Path PKG = (Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote\_build" r"\package_remote.py")) OLD = ''' wanted = sorted( [f for f in RELAY_SRC.iterdir() if f.suffix in (".py", ".sh") and f.is_file()], key=lambda f: f.name)''' NEW = ''' # 后缀白名单:.py / .sh 是服务本体,.ico 是管理页图标。 # 漏掉 .ico 的话,装到新设备上管理页又会变成没有图标的默认样式。 wanted = sorted( [f for f in RELAY_SRC.iterdir() if f.suffix in (".py", ".sh", ".ico") and f.is_file()], key=lambda f: f.name)''' def main() -> int: text = PKG.read_text(encoding="utf-8") if '.sh", ".ico"' in text: print(" 已经改过") return 0 if OLD not in text: print(" [失败] 锚点没找到") return 1 text = text.replace(OLD, NEW, 1) PKG.write_text(text, encoding="utf-8", newline="\n") print(" 服务器端打包现在会带上 .ico") try: ast.parse(text) print(" 语法 OK") except SyntaxError as exc: print(f" 语法错误: 行 {exc.lineno}: {exc.msg}") return 1 return 0 if __name__ == "__main__": sys.exit(main())