taolib.remote#
远端 SSH 自动化接口集合。
提供 SSH 配置读取/脱敏、prefix 上下文管理与远端探测接口(可注入 connection_factory 便于测试)。 更完整的使用说明见文档:doc/libs/python/Fabric/taolib_remote.md。
Submodules#
Attributes#
Exceptions#
配置不合法或缺失导致的错误。 |
|
依赖缺失或版本不兼容导致的错误。 |
|
远端命令执行失败导致的错误。 |
Classes#
SSH 连接配置结构(与 Fabric Connection 的关键字参数兼容)。 |
|
远端探测使用的命令集合。 |
|
远端探测结果。 |
|
远端命令执行选项与错误处理策略。 |
|
远端探测执行器(可注入连接工厂,便于测试与扩展)。 |
Functions#
|
从 TOML 读取 SSH 连接配置(返回深拷贝)。 |
|
脱敏 SSH 配置,避免输出敏感字段。 |
|
兼容接口:连接远端并执行探测命令,返回结构化结果。 |
|
在同一个命令执行上下文中叠加多个 prefix。 |
Package Contents#
- taolib.remote.load_ssh_config(config_path: str | pathlib.Path) SshConfig[源代码]#
从 TOML 读取 SSH 连接配置(返回深拷贝)。
- taolib.remote.redact_ssh_config(config: SshConfig | dict[str, Any]) dict[str, Any][源代码]#
脱敏 SSH 配置,避免输出敏感字段。
- exception taolib.remote.RemoteExecutionError(message: str, *, command: str | None = None)[源代码]#
Bases:
RemoteError远端命令执行失败导致的错误。
- command = None#
- class taolib.remote.RemoteProbeCommands[源代码]#
远端探测使用的命令集合。
命令分为两类: - prefix 命令:tools_env_cmd、conda_activate_cmd,会在同一执行上下文中叠加生效; - 常规命令:uname_cmd、check_conda_cmd、probe_cmd,会在远端依次运行。
- class taolib.remote.RemoteProbeReport[源代码]#
远端探测结果。
语义约定: - conda_available=False 时,不会尝试执行 probe_cmd(probe_attempted=False, probe_ok=None)。 - conda_available=True 且 probe_attempted=True 时,probe_ok 表示探测命令退出状态是否成功。
- class taolib.remote.RemoteProbeRunOptions[源代码]#
远端命令执行选项与错误处理策略。
encoding 与 run_kwargs 会被合并用于 Connection.run(...)。 raise_on_* 用于控制缺少 conda 或 probe 失败时,是返回结构化结果还是抛出异常。
- run_kwargs: collections.abc.Mapping[str, Any] | None = None#
- class taolib.remote.RemoteProber[源代码]#
远端探测执行器(可注入连接工厂,便于测试与扩展)。
- probe(ssh_config: collections.abc.Mapping[str, Any]) taolib.remote.probe_models.RemoteProbeReport[源代码]#
- taolib.remote.probe_remote(ssh_config: collections.abc.Mapping[str, Any], *, tools_env_cmd: str = DEFAULT_TOOLS_ENV_CMD, conda_activate_cmd: str = DEFAULT_CONDA_ACTIVATE_CMD, probe_cmd: str = DEFAULT_PROBE_CMD, encoding: str = DEFAULT_ENCODING, check_conda_cmd: str = 'command -v conda', uname_cmd: str = 'uname -a', connection_factory: taolib.remote.connection.ConnectionFactory | None = None, run_kwargs: collections.abc.Mapping[str, Any] | None = None, raise_on_conda_missing: bool = False, raise_on_probe_failure: bool = False) taolib.remote.probe_models.RemoteProbeReport[源代码]#
兼容接口:连接远端并执行探测命令,返回结构化结果。
- taolib.remote.remote_prefixes(connection: SupportsPrefix, *prefix_cmds: str) collections.abc.Iterator[None][源代码]#
在同一个命令执行上下文中叠加多个 prefix。