统一各站成败反馈信号;修复中通报错卡死与提示框误判
成败信号统一化(顺心/中通/韵达/安能/百世): - 各站 impl 开头清理上次的最终文件,避免无数据/失败时残留旧数据误导比对 - 轮询下载段加汇总校验:下载数 < 预期则 raise,堵住"零/部分下载被判成功" - 正常完成统一显式 return True(原中通/韵达/安能靠 None 隐式成功) - 无数据统一不落文件(安能实到不再落空 xlsx);韵达裸 except 改 except Exception - 中通"票数0无空提示"分支改判失败 中通 bug 修复(site_zto.py): - poll 加 stall 快速失败(连续4轮无进展即 raise)+ 刷新短超时 + 双失败 raise, 避免页面被遮挡时干等 5 分钟才触发重试 - "生成离线导出任务成功"提示所在 iframe 提交后被销毁,wait_for 抛 "Frame was detached" 属正常(提示已随 iframe 消失=任务已建立),改判成功 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -45,6 +45,15 @@ def baishi_reset(page):
|
||||
page.wait_for_timeout(1500)
|
||||
|
||||
|
||||
def _remove_if_exists(path):
|
||||
"""删除文件(若存在):流程开头清理上次的最终文件,避免无数据/失败时残留旧数据。"""
|
||||
try:
|
||||
if os.path.exists(path):
|
||||
os.remove(path)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def _close_tab(page, tab_name):
|
||||
"""关闭指定名称的百世标签页。
|
||||
|
||||
@@ -83,6 +92,9 @@ def baishi_download_undelivered_data_impl(page):
|
||||
if not os.path.exists(download_dir):
|
||||
os.makedirs(download_dir)
|
||||
|
||||
# 清理上次的最终文件,避免本次无数据/失败时残留旧数据误导比对
|
||||
_remove_if_exists(os.path.join(download_dir, "百世-应到未到货物数据.xlsx"))
|
||||
|
||||
try:
|
||||
# 1. 导航与页面加载
|
||||
print(">> 正在进入【扫描综合查询】界面...")
|
||||
@@ -111,7 +123,7 @@ def baishi_download_undelivered_data_impl(page):
|
||||
)
|
||||
# 数据为空时,提前结束前也需清理环境
|
||||
_close_tab(page, "扫描综合查询")
|
||||
return
|
||||
return True
|
||||
|
||||
# 有未扫数据,继续点击操作
|
||||
target_cell.locator("a").click()
|
||||
|
||||
Reference in New Issue
Block a user