jobflow_remote.remote.host.remote module#

class jobflow_remote.remote.host.remote.Interactive(username)[source]#

Bases: AuthSource

Interactive AuthSource. Prompts the user for all the requests coming from the server.

authenticate(transport)[source]#

Perform authentication.

class jobflow_remote.remote.host.remote.InteractiveAuthStrategy(ssh_config, fabric_config, username)[source]#

Bases: OpenSSHAuthStrategy

AuthStrategy based on OpenSSHAuthStrategy that tries to use public keys and then switches to an interactive approach forwarding the requests from the server.

Extends superclass with additional inputs.

Specifically:

  • fabric_config, a fabric.Config instance for the current session.

  • username, which is unified by our intended caller so we don’t have to - it’s a synthesis of CLI, runtime, invoke/fabric-configuration, and ssh_config configuration.

Also handles connecting to an SSH agent, if possible, for easier lifecycle tracking.

get_sources()[source]#

Generator yielding AuthSource instances, in the order to try.

This is the primary override point for subclasses: you figure out what sources you need, and yield them.

Subclasses _of_ subclasses may find themselves wanting to do things like filtering or discarding around a call to super.

class jobflow_remote.remote.host.remote.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.

close() bool[source]#
connect() None[source]#
property connection#
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.

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.

get(src, dst) None[source]#
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.

property is_connected: bool#
listdir(path: str | Path)[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 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:

bool

write_text_file(filepath: str | Path, content: str) None[source]#

Write content to a file on the host.

jobflow_remote.remote.host.remote.inter_handler(title, instructions, prompt_list)[source]#

Handler function for interactive prompts from the server. Used by Interactive AuthSource.