Files
tps-dashboard/doco/programs/ep002_20260127_qianting_fangsheng/_wait_fuse.py
T

40 lines
1.3 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
"""轮询等待 C3 fusion 完成"""
import os
import time
from pathlib import Path
ep_dir = Path(r"E:\tps-dashboard\doco\programs\ep002_20260127_qianting_fangsheng")
cache_dir = ep_dir / ".c3_cache"
expected_batches = 21 # 733 / 35
while True:
if not cache_dir.exists():
print("Cache dir not yet created, waiting 30s...")
time.sleep(30)
continue
n = len(list(cache_dir.iterdir()))
print(f"[{time.strftime('%H:%M:%S')}] Cache batches: {n}/{expected_batches}")
# Check if output file exists (fusion complete)
fuse_out = ep_dir / "融合B稿.txt"
if fuse_out.exists():
print(f"\n融合B稿.txt exists! ({fuse_out.stat().st_size} bytes)")
break
# Check if background process log indicates completion
log_dir = Path(r"C:\Users\Lenovo\AppData\Local\Temp\cline")
log_files = sorted(log_dir.glob("background-*.log"), key=lambda f: f.stat().st_mtime, reverse=True)
for lf in log_files[:3]:
content = lf.read_text(encoding="utf-8", errors="replace")
if "[ok] doco fuse" in content or "Exit code" in content:
print(f"\nBackground process completed (found in {lf.name})")
print(content[-1000:])
break
else:
time.sleep(60)
continue
break
print("Done waiting.")