- 新增 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 的负责人手机号做脱敏
43 lines
1.8 KiB
Python
43 lines
1.8 KiB
Python
"""临时校验:人工登录是否使用按账号隔离的浏览器用户目录(8 秒后超时,用完即删)。"""
|
|
import importlib.util
|
|
import os
|
|
import sys
|
|
|
|
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 金色湖畔扫码数据导出")
|
|
|
|
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)
|
|
|
|
from xq0079 import config # noqa: E402
|
|
from xq0079.data import tianque_browser # noqa: E402
|
|
|
|
config.set_log(lambda m, level="INFO": print(f"[{level}] {m}", flush=True))
|
|
config.set_debug(True)
|
|
|
|
ACCOUNT = env_get("tq_login_username")
|
|
ACCOUNT2 = env_get("tq_login_username_2") # 可选:第二个账号,用于校验 profile 目录按账号隔离
|
|
|
|
print("profile 根目录:", config.BROWSER_PROFILE_ROOT)
|
|
print("账号A 目录:", config.get_profile_dir(ACCOUNT))
|
|
if ACCOUNT2:
|
|
print("账号B 目录:", config.get_profile_dir(ACCOUNT2))
|
|
|
|
if not ACCOUNT or not env_get("tq_login_password"):
|
|
raise SystemExit("根 .env 缺 tq_login_username / tq_login_password,无法校验人工登录")
|
|
result = tianque_browser.manual_login(ACCOUNT, env_get("tq_login_password"), wait_seconds=6)
|
|
print("结果:", result.get("success"), result.get("message"))
|
|
print("临时公共目录是否被使用:", os.path.join(os.environ.get("TEMP", ""), "DrissionPage", "userData"))
|