# -*- coding: utf-8 -*- """用模拟 ctx 直接调用插件 run(),验证入口逻辑(导入、流程编排)。""" import importlib import json import os import sys try: sys.stdout.reconfigure(encoding='utf-8', errors='replace') except Exception: pass REPO = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) sys.path.insert(0, os.path.join(REPO, 'plugins', 'XQ0001-0100')) sys.path.insert(0, os.path.join(REPO, 'desktop', 'electron-shell', 'python')) class Ctx: def log(self, msg, level='INFO'): print(f'[{level}] {msg}', flush=True) def progress(self, pct): print(f'[进度] {pct}%', flush=True) PKG = 'XQ0076 交通银行数据导出' mod = importlib.import_module(PKG) cfg = importlib.import_module(PKG + '.config') plugins = getattr(mod, 'PLUGINS', []) print('注册插件数:', len(plugins), flush=True) if not plugins: sys.exit(1) plugin = plugins[0] print('插件:', plugin.id, plugin.version, flush=True) fields = { 'username': 'MER02797919', 'password': 'dummy-not-used-when-reused', 'date_mode': 'custom', 'date_from': sys.argv[1] if len(sys.argv) > 1 else '2026-10-31', 'date_to': sys.argv[2] if len(sys.argv) > 2 else '2026-10-31', 'mcht_id': '', 'mcht_acc': '', 'save_dir': os.path.join(REPO, 'logs', 'bankcomm_probe', 'run_out'), 'debug_mode': True, } try: result = plugin.run(fields, Ctx()) print('RESULT:', json.dumps(result, ensure_ascii=False, indent=1)[:1200], flush=True) except Exception as e: print('FAILED:', type(e).__name__, e, flush=True) sys.exit(1)