_refresh_toc_v05.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # -*- coding: utf-8 -*-
  2. """用 Word 刷新本次新/改的 10 份交付文档目录域(TOC 域缓存为空,需 Word 打开刷新)。"""
  3. from __future__ import annotations
  4. import subprocess
  5. import sys
  6. import time
  7. from pathlib import Path
  8. HERE = Path(__file__).resolve().parent
  9. WORKER = HERE / "_word_toc_one.py"
  10. TARGET = Path(r"C:\Users\skygu\OneDrive\Projects\AIDOP\项目\项目管理\产互联项目管理\交付文档\Release产互联\待确认")
  11. FILES = [
  12. "系统集成业务需求描述-V0.5.docx",
  13. "系统集成模块蓝图设计方案-V0.5.docx",
  14. "系统集成模块详细设计说明书-V0.5.docx",
  15. "系统集成-用户操作手册-V0.5.docx",
  16. "运营改善业务需求描述-V0.5.docx",
  17. "运营改善模块蓝图设计方案-V0.5.docx",
  18. "运营改善模块详细设计说明书-V0.5.docx",
  19. "运营改善-用户操作手册-V0.5.docx",
  20. "九宫格智慧运营看板模块详细设计说明书-V0.1.docx",
  21. "九宫格智慧运营看板-用户操作手册-V0.1.docx",
  22. ]
  23. def main():
  24. for name in FILES:
  25. p = TARGET / name
  26. if not p.exists():
  27. print("MISS", name, flush=True)
  28. continue
  29. t0 = time.time()
  30. proc = subprocess.run(
  31. [sys.executable, str(WORKER), str(p)],
  32. capture_output=True,
  33. text=True,
  34. timeout=300,
  35. check=False,
  36. )
  37. out = (proc.stdout or "").strip()
  38. err = (proc.stderr or "").strip()
  39. status = "OK" if proc.returncode == 0 else "FAIL"
  40. print(f"{status} {name} {out or err} {time.time()-t0:.0f}s", flush=True)
  41. if __name__ == "__main__":
  42. main()