Remote
Remote
Used to run commands over SSH asynchronously in subprocesses while sharing an SSH connection.
This doesn't work on Windows, as it assumes that the SSH client has SSH multiplexing support (ControlMaster, ControlPath and ControlPersist).
- Reference Cli
connect
Async 'constructor'.
Using this once explicitly before running lots of commands in parallel can be useful, since otherwise the 2FA prompt might happen for each individual command.
TODO: cache this function's result using an async-compatible version of functools.cache maybe?
run
run(
program_and_args: tuple[str, ...],
input: str | None = None,
warn: bool = False,
hide: Hide = False,
_stacklevel: int = 2,
_display: bool | str = False,
) -> CompletedProcess[str]
Runs the command asynchronously in a subprocess and returns the result.
Parameters
program_and_args: The program and arguments to pass to it. This is a tuple of strings, same as in subprocess.Popen.
input: The optional 'input' argument to subprocess.Popen.communicate().
warn: When True and an exception occurs, warn instead of raising the exception.
hide: Controls the printing of the subprocess' stdout and stderr.
Returns
A subprocess.CompletedProcess object with the result of the asyncio.Process.
Raises
subprocess.CalledProcessError
If an error occurs when running the command and warn is False.
control_socket_is_running
Asynchronously checks whether the control socket at the given path is running.