Files
puddy b20fc3d099 refactor(tests): 探针脚本凭据改为从根 .env 读取,移除硬编码账号密码
- 新增 tests/_env.py:统一读仓库根 .env(仅标准库,进程内缓存)
- tianque 探针 6 个脚本改读 tq_login_username / tq_login_password,account.json 仅兜底
- workflows/share/erp_login.py 的 __main__ 去掉硬编码 ERP 账号密码(改由 .env 提供)
- docs/需求单/README.md 的负责人手机号做脱敏
2026-11-18 20:22:38 +08:00

50 lines
1.5 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""临时联调:按壳子方式加载 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)