restore: 恢复 11-06~11-09 本地未提交改动
- libs: 新增 hr_sdk / hotel_report / dingtalk,更新 desktopauto - controlplane-next: SDK 管理模块(controller/entity/migrations)与前端视图 - electron-shell: 插件同步、注册表、runner 调整 - plugins: XQ0035/XQ0041/XQ0042/XQ0045_XQ0046/XQ0048/XQ0076/XQ0078 等版本更新 - tests/tools: 新增 SDK 兼容性检查与打包工具(sdk_pack.py、sdk_compat_check.py)
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""XQ0052 插件级端到端:按壳子的加载方式加载插件,用真实 WCF 跑一次 run()。
|
||||
|
||||
验证链路:插件 run() → SDK 挂载 → settle_window → export_member → 两份 Excel。
|
||||
|
||||
用法(项目根):
|
||||
.venv\\Scripts\\python.exe tests\\xq0052_湖畔储值卡\\plugin_e2e.py
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib.util
|
||||
import os
|
||||
import sys
|
||||
|
||||
BASE = os.path.dirname(os.path.abspath(__file__))
|
||||
ROOT = os.path.abspath(os.path.join(BASE, "..", ".."))
|
||||
PLUGIN_DIR = os.path.join(ROOT, "plugins", "XQ0001-0100", "XQ0052 湖畔储值卡每日导出统计")
|
||||
|
||||
sys.path.insert(0, os.path.join(ROOT, "desktop", "electron-shell", "python")) # webhost 包
|
||||
sys.path.insert(0, os.path.join(ROOT, "libs", "hotel_report")) # 开发态 SDK
|
||||
|
||||
|
||||
class _Ctx:
|
||||
def __init__(self):
|
||||
self.lines = []
|
||||
|
||||
def log(self, msg, level="INFO"):
|
||||
self.lines.append(msg)
|
||||
print(f" [{level}] {msg}")
|
||||
|
||||
def progress(self, pct):
|
||||
if int(pct) in (5, 50, 55, 100):
|
||||
print(f" [progress] {int(pct)}%")
|
||||
|
||||
|
||||
def load_plugin():
|
||||
spec = importlib.util.spec_from_file_location(
|
||||
"xq0052_plugin", os.path.join(PLUGIN_DIR, "__init__.py"),
|
||||
submodule_search_locations=[PLUGIN_DIR])
|
||||
mod = importlib.util.module_from_spec(spec)
|
||||
sys.modules["xq0052_plugin"] = mod
|
||||
spec.loader.exec_module(mod)
|
||||
return mod.PLUGINS[-1]
|
||||
|
||||
|
||||
def main() -> int:
|
||||
if hasattr(sys.stdout, "reconfigure"):
|
||||
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
||||
plugin = load_plugin()
|
||||
print(f"插件:{plugin.id} {plugin.name} v{plugin.version}")
|
||||
|
||||
out_dir = os.path.join(BASE, "out")
|
||||
os.makedirs(out_dir, exist_ok=True)
|
||||
ctx = _Ctx()
|
||||
res = plugin.run({"day": "", "save_dir": out_dir}, ctx)
|
||||
|
||||
print("\n" + res["summary"])
|
||||
print("\n产出:")
|
||||
ok = True
|
||||
for p in res.get("files") or []:
|
||||
size = os.path.getsize(p) / 1024 / 1024 if os.path.isfile(p) else 0
|
||||
print(f" {os.path.basename(p)} {size:.2f} MB {'OK' if size else '✗ 缺失'}")
|
||||
ok &= bool(size)
|
||||
print(f"\n链路:{'OK' if ok else '✗'}")
|
||||
return 0 if ok else 2
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user