"""临时诊断:跑 TPV 编译指定项目,捕获完整输出并过滤关键行""" import subprocess import sys exe = r"d:\Users\TermiNexus\Desktop\TransPyC\TransPyV\output\TransPyV.exe" proj = sys.argv[1] if len(sys.argv) > 1 else "SuperTest" r = subprocess.run([exe, "--project", proj, "--clean"], cwd=r"d:\Users\TermiNexus\Desktop\TransPyC\Test", capture_output=True, text=True, encoding='utf-8', errors='replace') out = (r.stdout or "") + (r.stderr or "") print(f"RETURNCODE={r.returncode}") keep = ["Error", "WARN [HandlesExprCall]", "SyntaxError", "Traceback", "NameError", "TypeError", "InternalCompilerError", "Exception", "line ", "翻译完成(translate返回)", "SUCCESS", "FAILED"] for line in out.splitlines(): if any(k in line for k in keep): print(line)