1
This commit is contained in:
1 parent
a85f53257f
commit
dc2f8a299f
1 file changed
+23
-1
@@ -103,7 +103,29 @@ 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)
|
||||
# 使用 Popen 来执行命令
|
||||
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
|
||||
# 检查命令是否执行完毕
|
||||
while True:
|
||||
return_code = process.poll() # 获取进程的退出码,None 表示进程仍在运行
|
||||
if return_code is not None:
|
||||
print("Command finished with return code:", return_code)
|
||||
break
|
||||
print("Command is still running...")
|
||||
time.sleep(1) # 每秒检查一次进程状态
|
||||
|
||||
# 获取命令的输出
|
||||
stdout, stderr = process.communicate()
|
||||
|
||||
# 打印输出结果
|
||||
if return_code == 0:
|
||||
print("Command executed successfully.")
|
||||
print(f"Output: {stdout.decode()}")
|
||||
else:
|
||||
print(f"Command failed with return code {return_code}")
|
||||
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)}')
|
||||
|
||||
Reference in new issue
Block a user