jobflow_remote.remote.host.local module#

class jobflow_remote.remote.host.local.LocalHost(timeout_execute: int = None)[source]#

Bases: BaseHost

close() bool[source]#
connect() None[source]#
copy(src, dst) None[source]#
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.

Parameters:

command (str or list of str) – Command to execute, as a str or list of str

Returns:

  • stdout (str) – Standard output of the command

  • stderr (str) – Standard error of the command

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

get(src, dst) None[source]#
property is_connected: bool#
listdir(path: str | Path) list[str][source]#
mkdir(directory: str | Path, recursive: bool = True, exist_ok: bool = True) bool[source]#

Create directory on the host.

put(src, dst) None[source]#
remove(path: str | Path) None[source]#
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:

bool

write_text_file(filepath, content) None[source]#

Write content to a file on the host.