41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
"""仿真账号来源封装(示例级;真实 skill 可在此集中对接 account-manager)。"""
|
||
|
||
from __future__ import annotations
|
||
|
||
import os
|
||
from dataclasses import dataclass
|
||
from typing import Optional
|
||
|
||
from util.constants import (
|
||
DEFAULT_DEMO_LOGIN_ID,
|
||
DEFAULT_DEMO_PASSWORD,
|
||
DEFAULT_DEMO_TOKEN_PIN,
|
||
ENV_SIMULATOR_LOGIN_ID,
|
||
ENV_SIMULATOR_PASSWORD,
|
||
ENV_SIMULATOR_PROFILE_DIR,
|
||
ENV_SIMULATOR_TOKEN_PIN,
|
||
)
|
||
|
||
|
||
@dataclass
|
||
class SimulatorAccount:
|
||
login_id: str
|
||
password: str
|
||
token_pin: str
|
||
profile_dir: str = ""
|
||
|
||
|
||
def pick_simulator_account() -> SimulatorAccount:
|
||
"""
|
||
示例账号来源:优先读环境变量,否则返回内置 demo 账号。
|
||
|
||
真实 skill 若依赖 account-manager,应把 subprocess / sibling_bridge 调用
|
||
集中在本模块,不要散落到 task_service 或 RPA 主流程中。
|
||
"""
|
||
return SimulatorAccount(
|
||
login_id=(os.getenv(ENV_SIMULATOR_LOGIN_ID) or DEFAULT_DEMO_LOGIN_ID).strip(),
|
||
password=(os.getenv(ENV_SIMULATOR_PASSWORD) or DEFAULT_DEMO_PASSWORD).strip(),
|
||
token_pin=(os.getenv(ENV_SIMULATOR_TOKEN_PIN) or DEFAULT_DEMO_TOKEN_PIN).strip(),
|
||
profile_dir=(os.getenv(ENV_SIMULATOR_PROFILE_DIR) or "").strip(),
|
||
)
|