fix: Add flush=True to print statements and improve task status check
- Added flush=True to print statements for better real-time logging - Replaced single status check with a list of statuses to continue waiting - Defined constants for task status values for better code readability
This commit is contained in:
parent
0be6ca7e33
commit
42c4386562
@ -48,13 +48,13 @@ def check_api_version():
|
||||
return
|
||||
|
||||
local_version = get_local_version()
|
||||
print("检查被测服务器文档是否已经更新到最新版本...")
|
||||
print("检查被测服务器文档是否已经更新到最新版本...", flush=True)
|
||||
while True:
|
||||
try:
|
||||
res = session.get(VERSION_URL)
|
||||
version = res.json()["version"]
|
||||
if version == local_version:
|
||||
print(f"API 文档已更新,当前版本为 {version},开始上传 OpenAPI 文档...")
|
||||
print(f"API 文档已更新,当前版本为 {version},开始上传 OpenAPI 文档...", flush=True)
|
||||
break
|
||||
else:
|
||||
print(
|
||||
@ -126,7 +126,11 @@ def wait_for_task_done(task_id):
|
||||
res = session.get(f"{SERVER_URL}/tasks/{task_id}")
|
||||
data = res.json()
|
||||
status = data["status"]
|
||||
if status == "succeeded":
|
||||
|
||||
CREATED = "created"
|
||||
RUNNING = "running"
|
||||
WAITING = "waiting"
|
||||
if status not in [CREATED, RUNNING, WAITING]:
|
||||
print("自动测试脚本执行完成!", flush=True)
|
||||
break
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user