"""临时联调:按壳子方式加载 xq0079 并跑 run(login_mode=人工登录,缓存 token 有效时应直接复用)。""" import importlib.util import os import sys import tempfile if hasattr(sys.stdout, "reconfigure"): sys.stdout.reconfigure(encoding="utf-8", errors="replace") REPO = r"d:\work\code\37duAutomation" sys.path.insert(0, os.path.join(REPO, "desktop", "electron-shell", "python")) sys.path.insert(0, os.path.join(REPO, "tests")) from _env import get as env_get # noqa: E402 PLUGIN_DIR = os.path.join(REPO, "plugins", "XQ0001-0100", "XQ0079 金色湖畔扫码数据导出") class FakeCtx: def log(self, msg, level="INFO"): print(f"[{level}] {msg}", flush=True) def progress(self, pct): pass spec = importlib.util.spec_from_file_location( "xq0079", os.path.join(PLUGIN_DIR, "__init__.py"), submodule_search_locations=[PLUGIN_DIR]) mod = importlib.util.module_from_spec(spec) sys.modules["xq0079"] = mod spec.loader.exec_module(mod) plugin = mod.PLUGINS.find("xq0079") fields = { "tq_account1": env_get("tq_login_username"), "tq_password1": env_get("tq_login_password"), "tq_account2": env_get("tq_login_username_2"), "tq_password2": env_get("tq_login_password_2"), "login_mode": "人工登录", "date_from": "", "date_to": "", "save_dir": os.path.join(tempfile.gettempdir(), "xq0079_test"), "debug_mode": False, } result = plugin.run(fields, FakeCtx()) print("\nsummary:", result.get("summary")) for note in result.get("notes") or []: print("note:", note)