waft.system.clients.client_base module¶
- class waft.system.clients.client_base.ClientBase(connection_details: ConnectionDetails)¶
Bases:
ABC
Base class for remote communication clients
- add_env_var(var, value)¶
Add given value to env under given name
- add_to_path(path: str)¶
Add given path to PATH env var
- bind_remote_port_to_local(remote_port: int, local_port: int, remote_host: str = 'localhost', local_host: str = 'localhost')¶
Bind a port on the remote machine to a port on localhost. This is intended for use on systems behind a proxy
- Parameters:
remote_port – Port number on remote machine to bind to a port on localhost
local_port – Port on test runner that should be bound to given remote port
remote_host – Host on remote port for which the given port is to be forwarded (Default: localhost)
local_host – Local host to which given port should be forwarded (Default: localhost)
- default_timeout: float | None = 300¶
- abstractmethod exec_command(command: list, input: str | list[str] | None = None, retry_handler: RetryHandler | None = None, expected_exit_code: int | None = 0, auto_raise: bool = True, custom_exception: Type[Exception] | None = None, custom_exception_msg: str | None = None, **kwargs) Result ¶
Execute a command on a remote system
Args:¶
command (list[str]): The system command to execute. input (Optional[str | list[str]]): Command input. retry_handler (Optional[RetryHandler]): An instance of RetryHandler if specific retry configurations are desired. expected_exit_code (Optional[int]): The expected exit code of the command. Defaults to 0. auto_raise (bool): Whether to automatically raise an exception if the command’s exit code does not match the expected_exit_code. Defaults to True. custom_exception (Optional[Type[Exception]]): Custom exception to raise if the command status is not the expected_exit_code. Defaults to None. custom_exception_msg (Optional[str]): Custom message to include with the custom exception. Defaults to None. **kwargs: Custom keyword arguments for client execution
- get_file(remote_file_path: PurePath, local_file_path: Path) None ¶
Get a file from a remote system
- property is_remote: bool¶
Indicate whether this is a remote client.
- Returns:
True if this is a remote client. False if this is a local client.
- Return type:
bool
- reset_connection()¶
Reset connection and clear any cache for the current session
- send_file(remote_file_path: PurePath, local_file_path: Path) None ¶
Send a file to a remote system
- property ssh: SshConnection¶
Returns an initialized SSH connection
- test_connection()¶
Test the connection to the remote system