#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""probe_shaowu_exit.py —— shaowu 0 秒早退取证"""
import re, subprocess
D = "/root/gov_crawler/"; f = "crawl_shaowu.py"
src = open(D + f, encoding="utf-8").read()
print("文件 %d 字节 / %d 行" % (len(src), src.count("\n") + 1))
print("=== 早退/条件相关行 ===")
for i, ln in enumerate(src.split("\n"), 1):
    if re.search(r"sys\.exit|return\b|if not |已有|无需|no new|跳过全部|CUTOFF|cutoff", ln):
        print("  L%-4d %s" % (i, ln.strip()[:118]))
print("\n=== 实跑完整输出 ===")
r = subprocess.run(["python3", D + f], capture_output=True, text=True, timeout=120, cwd=D)
print("EXIT=%d" % r.returncode)
for x in (r.stdout or "").split("\n"):
    if x.strip(): print("  out:", x[:118])
for x in (r.stderr or "").split("\n")[-4:]:
    if x.strip(): print("  ERR:", x[:118])
