| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- # -*- coding: utf-8 -*-
- """批量刷新 S1 风格 20 份交付文档的目录域(逐文件独立 Word 进程)。"""
- import subprocess
- import sys
- from pathlib import Path
- HERE = Path(__file__).resolve().parent
- sys.path.insert(0, str(HERE))
- from _gen_s1style_delivery import DELIVER, PENDING # noqa: E402
- FILES = [fname for dl in DELIVER.values() for fname in dl["files"].values()]
- def main():
- ok = 0
- for f in FILES:
- p = PENDING / f
- if not p.exists():
- print("MISS", f, flush=True)
- continue
- try:
- r = subprocess.run(
- [sys.executable, str(HERE / "_word_toc_one.py"), str(p)],
- capture_output=True, text=True, timeout=300,
- )
- out = (r.stdout or "").strip().replace("\n", " ")
- err = (r.stderr or "").strip().splitlines()
- tag = "OK " if r.returncode == 0 else "ERR"
- print(f"{tag} {f} {out}", flush=True)
- if r.returncode != 0 and err:
- print(" ", err[-1][:160], flush=True)
- if r.returncode == 0:
- ok += 1
- except Exception as exc:
- print(f"ERR {f} {exc}", flush=True)
- print(f"DONE {ok}/{len(FILES)}", flush=True)
- if __name__ == "__main__":
- main()
|