qtoolkit.host.remote module#

class qtoolkit.host.remote.RemoteConfig(root_dir: 'str | Path', host: 'str', user: 'str' = None, port: 'int' = None, config: 'fabric.Config' = <factory>, gateway: 'fabric.Connection | str' = None, forward_agent: 'bool' = None, connect_timeout: 'int' = None, connect_kwargs: 'dict' = None, inline_ssh_env: 'bool' = True)[source]#

Bases: HostConfig

config: Config#
connect_kwargs: dict = None#
connect_timeout: int = None#
forward_agent: bool = None#
gateway: Connection | str = None#
host: str#
inline_ssh_env: bool = True#
port: int = None#
user: str = None#
class qtoolkit.host.remote.RemoteHost(config: RemoteConfig)[source]#

Bases: BaseHost

Execute commands on a remote host. For some commands assumes the remote can run unix

property connection#
execute(command: str | list[str], workdir: str | Path | None = None)[source]#

Execute the given command on the host

Parameters:
  • command (str or list of str) – Command to execute, as a str or list of str.

  • workdir (str or None) – path where the command will be executed.

Returns:

  • stdout (str) – Standard output of the command

  • stderr (str) – Standard error of the command

  • exit_code (int) – Exit code of the command.

mkdir(directory, recursive: bool = True, exist_ok: bool = True) bool[source]#

Create directory on the host.

write_text_file(filepath, content)[source]#

Write content to a file on the host.