From af67fbcc0cbcf404979b6b71fa0603da26a078fa Mon Sep 17 00:00:00 2001 From: dongchangxi <458593490@qq.com> Date: Sat, 11 Jan 2025 23:47:31 +0800 Subject: [PATCH] 1 --- yj_local_build/main_step1.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/yj_local_build/main_step1.py b/yj_local_build/main_step1.py index 08f0a26..61d3ef7 100644 --- a/yj_local_build/main_step1.py +++ b/yj_local_build/main_step1.py @@ -103,7 +103,26 @@ def detect_markers(psid, pid): {textpicCmd} -save "{os.path.join(config["workdir"], pid, f"{pid}.rcproj")}" -quit' print(cmd) cmd = shlex.split(cmd) - res = subprocess.run(cmd) + #res = subprocess.run(cmd) + + # ######################################## + + process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + # 检查进程是否完成 + while True: + retcode = process.poll() # 返回值为None表示进程尚未结束 + if retcode is not None: + # 如果进程已经完成,打印退出状态码 + print(f"Process exited with code: {retcode}") + break + else: + print("Process is still running...") + time.sleep(1) # 每隔1秒检查一次 + stdout, stderr = process.communicate() + print(f"Output: {stdout.decode()}") + print(f"Error: {stderr.decode()}") + # ######################################## + time.sleep(3) fix_region() print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} pid: {pid} 定位点检测完成, 共费时{diff_time(start_time)}')