Add per-site exception fallback (reset + retry), router stays pure dispatch
每个站点模块自带"失败→重置回初始态→重试"兜底(最多 3 次,含首次;每次 失败都重置,含最终放弃那次清场),对外只暴露 xxx_download 公开入口,路由 层无感、只负责调度。 - 各站点模块新增:HOME_URL、xxx_reset、内联 with_retry;原流程拆为 xxx_download(带重试) + xxx_download_impl(单次,供自动化测试探测原始失败)。 - 网页站重置=goto 首页 URL;安能(Electron)重置=关业务 tab+收菜单(实测 reload 会留下杀不掉的僵尸 webContents,故不用 reload)。 - main_router:SITES_CONFIG 改引用各模块 HOME_URL(单一来源);菜单分派回归 朴素调用;run_automation_test 改走 _impl 以保留"暴露问题"的测试本意。 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -20,12 +20,12 @@ import site_anneng
|
||||
# 应到未到比对(全站点,离线处理 downloads/ 下的应到/实到数据)
|
||||
import expected_undelivered
|
||||
|
||||
# 定义网点及对应的初始登录 URL
|
||||
# 各网页站点首页 URL 统一取自对应站点模块的 HOME_URL(单一来源,不在两处维护)。
|
||||
SITES_CONFIG = {
|
||||
"顺心": "https://sxne.sxjdfreight.com",
|
||||
"百世": "https://v5.800best.com",
|
||||
"中通": "https://ws.zto56.com/",
|
||||
"韵达": "https://ky-sso.yunda56.com",
|
||||
"顺心": site_shunxin.HOME_URL,
|
||||
"百世": site_baishi.HOME_URL,
|
||||
"中通": site_zto.HOME_URL,
|
||||
"韵达": site_yunda.HOME_URL,
|
||||
}
|
||||
|
||||
# ====================================================================
|
||||
@@ -104,22 +104,24 @@ def run_automation_test(pages_map):
|
||||
判定规则:流程函数返回 False 或抛出异常记为 FAIL,其余记为 PASS。
|
||||
"""
|
||||
# 站点 -> {流程键: (中文名, 流程函数)};百世为单流程,单独处理
|
||||
# 自动化测试刻意走各站点的 _impl(单次执行、无兜底重试),以便探测原始失败、
|
||||
# 不被模块内部"失败→重置→重试"机制掩盖。
|
||||
flow_table = {
|
||||
"顺心": {
|
||||
"expected": ("应到", site_shunxin.shunxin_expected_download),
|
||||
"actual": ("实到", site_shunxin.shunxin_actual_download),
|
||||
"expected": ("应到", site_shunxin.shunxin_expected_download_impl),
|
||||
"actual": ("实到", site_shunxin.shunxin_actual_download_impl),
|
||||
},
|
||||
"中通": {
|
||||
"expected": ("应到", site_zto.zto_expected_download),
|
||||
"actual": ("实到", site_zto.zto_actual_download),
|
||||
"expected": ("应到", site_zto.zto_expected_download_impl),
|
||||
"actual": ("实到", site_zto.zto_actual_download_impl),
|
||||
},
|
||||
"韵达": {
|
||||
"expected": ("应到", site_yunda.yunda_expected_download),
|
||||
"actual": ("实到", site_yunda.yunda_actual_download),
|
||||
"expected": ("应到", site_yunda.yunda_expected_download_impl),
|
||||
"actual": ("实到", site_yunda.yunda_actual_download_impl),
|
||||
},
|
||||
"安能": {
|
||||
"expected": ("应到", site_anneng.anneng_expected_download),
|
||||
"actual": ("实到", site_anneng.anneng_actual_download),
|
||||
"expected": ("应到", site_anneng.anneng_expected_download_impl),
|
||||
"actual": ("实到", site_anneng.anneng_actual_download_impl),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -133,7 +135,9 @@ def run_automation_test(pages_map):
|
||||
plan.append((site_name, label, func))
|
||||
# 百世:单流程,跑一次即可
|
||||
if "百世" in pages_map:
|
||||
plan.append(("百世", "应到未到", site_baishi.baishi_download_undelivered_data))
|
||||
plan.append(
|
||||
("百世", "应到未到", site_baishi.baishi_download_undelivered_data_impl)
|
||||
)
|
||||
|
||||
if not plan:
|
||||
print("\n⚠️ 当前没有已就绪的站点,无法执行自动化测试。")
|
||||
@@ -419,26 +423,33 @@ def run_multi_site_daemon():
|
||||
|
||||
try:
|
||||
if choice == "1" and is_site_ready("顺心"):
|
||||
pages_map["顺心"].bring_to_front()
|
||||
site_shunxin.shunxin_expected_download(pages_map["顺心"])
|
||||
page = pages_map["顺心"]
|
||||
page.bring_to_front()
|
||||
site_shunxin.shunxin_expected_download(page)
|
||||
elif choice == "2" and is_site_ready("顺心"):
|
||||
pages_map["顺心"].bring_to_front()
|
||||
site_shunxin.shunxin_actual_download(pages_map["顺心"])
|
||||
page = pages_map["顺心"]
|
||||
page.bring_to_front()
|
||||
site_shunxin.shunxin_actual_download(page)
|
||||
elif choice == "3" and is_site_ready("百世"):
|
||||
pages_map["百世"].bring_to_front()
|
||||
site_baishi.baishi_download_undelivered_data(pages_map["百世"])
|
||||
page = pages_map["百世"]
|
||||
page.bring_to_front()
|
||||
site_baishi.baishi_download_undelivered_data(page)
|
||||
elif choice == "4" and is_site_ready("中通"):
|
||||
pages_map["中通"].bring_to_front()
|
||||
site_zto.zto_expected_download(pages_map["中通"])
|
||||
page = pages_map["中通"]
|
||||
page.bring_to_front()
|
||||
site_zto.zto_expected_download(page)
|
||||
elif choice == "5" and is_site_ready("中通"):
|
||||
pages_map["中通"].bring_to_front()
|
||||
site_zto.zto_actual_download(pages_map["中通"])
|
||||
page = pages_map["中通"]
|
||||
page.bring_to_front()
|
||||
site_zto.zto_actual_download(page)
|
||||
elif choice == "6" and is_site_ready("韵达"):
|
||||
pages_map["韵达"].bring_to_front()
|
||||
site_yunda.yunda_expected_download(pages_map["韵达"])
|
||||
page = pages_map["韵达"]
|
||||
page.bring_to_front()
|
||||
site_yunda.yunda_expected_download(page)
|
||||
elif choice == "7" and is_site_ready("韵达"):
|
||||
pages_map["韵达"].bring_to_front()
|
||||
site_yunda.yunda_actual_download(pages_map["韵达"])
|
||||
page = pages_map["韵达"]
|
||||
page.bring_to_front()
|
||||
site_yunda.yunda_actual_download(page)
|
||||
elif choice == "10" and is_site_ready("安能"):
|
||||
site_anneng.anneng_expected_download()
|
||||
elif choice == "11" and is_site_ready("安能"):
|
||||
|
||||
Reference in New Issue
Block a user