Exec

class rmote.tools.exec.Exec[source]

Bases: Tool

Run commands and shell expressions on the remote host.

static command(*args, check=True, env=None, cwd=None, stdin=None)[source]

Run a command with explicit argument list.

Parameters:
  • *args (Text) – Command and its arguments (e.g. "ls", "-la").

  • check (bool) – Raise subprocess.CalledProcessError on non-zero exit.

  • env (WSGIEnvironment[Text, Text] | None) – Override environment variables for the subprocess.

  • cwd (None | Text | Path) – Working directory; defaults to the remote process’s cwd.

  • stdin (None | Text | bytes) – Data written to stdin before the command reads it.

Return type:

CompletedProcess[Any]

Returns:

subprocess.CompletedProcess with returncode, stdout, and stderr.

static shell(expression, check=True, env=None, cwd=None, stdin=None)[source]

Run expression through the remote shell (/bin/sh -c).

Parameters:
  • expression (Text) – Shell expression, including pipes, redirects, etc.

  • check (bool) – Raise subprocess.CalledProcessError on non-zero exit.

  • env (WSGIEnvironment[Text, Text] | None) – Override environment variables for the subprocess.

  • cwd (None | Text | Path) – Working directory; defaults to the remote process’s cwd.

  • stdin (None | Text | bytes) – Data written to stdin before the command reads it.

Return type:

CompletedProcess[Any]

Returns:

subprocess.CompletedProcess with returncode, stdout, and stderr.