jobflow_remote.remote.host package#
Submodules#
Module contents#
- class jobflow_remote.remote.host.BaseHost[source]#
Bases:
MSONable
Base Host class.
- abstract execute(command: str | list[str], workdir: str | Path | None = None, timeout: int | None = None) tuple[str, str, int] [source]#
Execute the given command on the host.
- property interactive_login: bool#
True if the host requires interactive actions upon login. False by default. Subclasses should override the method to customize the value.
- abstract mkdir(directory: str | Path, recursive: bool = True, exist_ok: bool = True) bool [source]#
Create directory on the host.
- abstract rmtree(path: str | Path, raise_on_error: bool = False) bool [source]#
Recursively delete a directory tree on a host.
This method must be implemented by subclasses of BaseHost. It is intended to remove an entire directory tree, including all files and subdirectories, on the host represented by the subclass.
- Parameters:
path (str or Path) – The path to the directory tree to be removed.
raise_on_error (bool) – If set to False (default), errors will be ignored, and the method will attempt to continue removing remaining files and directories. Otherwise, any errors encountered during the removal process will raise an exception.
- Returns:
True if the directory tree was successfully removed, False otherwise.
- Return type:
- class jobflow_remote.remote.host.LocalHost(timeout_execute: int = None)[source]#
Bases:
BaseHost
- execute(command: str | list[str], workdir: str | Path | None = None, timeout: int | None = None)[source]#
Execute the given command on the host.
Note that the command is executed with shell=True, so commands can be exposed to command injection. Consider whether to escape part of the input if it comes from external users.
- mkdir(directory: str | Path, recursive: bool = True, exist_ok: bool = True) bool [source]#
Create directory on the host.
- rmtree(path: str | Path, raise_on_error: bool = False) bool [source]#
Recursively delete a directory tree on a local host.
It is intended to remove an entire directory tree, including all files and subdirectories, on this local host.
- Parameters:
path (str or Path) – The path to the directory tree to be removed.
raise_on_error (bool) – If set to False (default), errors will be ignored, and the method will attempt to continue removing remaining files and directories. Otherwise, any errors encountered during the removal process will raise an exception.
- Returns:
True if the directory tree was successfully removed, False otherwise.
- Return type:
- class jobflow_remote.remote.host.RemoteHost(host, user=None, port=None, config=None, gateway=None, forward_agent=None, connect_timeout=None, connect_kwargs=None, inline_ssh_env=None, timeout_execute=None, keepalive=60, shell_cmd='bash', login_shell=True, retry_on_closed_connection=True, interactive_login=False)[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, timeout: int | None = None)[source]#
Execute the given command on the host.
- property interactive_login: bool#
True if the host requires interactive actions upon login. False by default. Subclasses should override the method to customize the value.
- mkdir(directory: str | Path, recursive: bool = True, exist_ok: bool = True) bool [source]#
Create directory on the host.
- rmtree(path: str | Path, raise_on_error: bool = False) bool [source]#
Recursively delete a directory tree on a remote host.
It is intended to remove an entire directory tree, including all files and subdirectories, on this remote host.
- Parameters:
path (str or Path) – The path to the directory tree to be removed.
raise_on_error (bool) – If set to False (default), errors will be ignored, and the method will attempt to continue removing remaining files and directories. Otherwise, any errors encountered during the removal process will raise an exception.
- Returns:
True if the directory tree was successfully removed, False otherwise.
- Return type: