bartender.schedulers.runner#

Classes#

CommandRunner

Protocol for running a command.

LocalCommandRunner

Runs command on system where current Python process is running.

SshCommandRunner

Run command on a remote machine using SSH.

Module Contents#

class bartender.schedulers.runner.CommandRunner#

Bases: Protocol

Protocol for running a command.

async run(command: str, args: list[str], stdin: str | None = None, cwd: pathlib.Path | None = None) tuple[int, str, str]#

Run command.

Parameters:
  • command (str) – Command to execute. Command can not contain spaces.

  • args (list[str]) – List of arguments for command. Argument containing spaces should be wrapped in quotes.

  • stdin (Optional[str]) – Input for command.

  • cwd (Optional[pathlib.Path]) – In which directory the command should be run.

Returns:

Tuple with return code, stdout and stderr.

Return type:

tuple[int, str, str]

close() None#

Close any connections runner has.

Return type:

None

class bartender.schedulers.runner.LocalCommandRunner#

Bases: CommandRunner

Runs command on system where current Python process is running.

async run(command: str, args: list[str], stdin: str | None = None, cwd: pathlib.Path | None = None) tuple[int, str, str]#

Run command.

Parameters:
  • command (str) – Command to execute. Command can not contain spaces.

  • args (list[str]) – List of arguments for command. Argument containing spaces should be wrapped in quotes.

  • stdin (Optional[str]) – Input for command.

  • cwd (Optional[pathlib.Path]) – In which directory the command should be run.

Raises:

ValueError – Command is both running and dead.

Returns:

Tuple with return code, stdout and stderr.

Return type:

tuple[int, str, str]

close() None#

Close any connections runner has.

Return type:

None

__eq__(other: object) bool#
Parameters:

other (object) –

Return type:

bool

class bartender.schedulers.runner.SshCommandRunner(config: bartender.shared.ssh.SshConnectConfig)#

Bases: CommandRunner

Run command on a remote machine using SSH.

Parameters:

config (bartender.shared.ssh.SshConnectConfig) –

config#
conn: asyncssh.SSHClientConnection | None = None#
async run(command: str, args: list[str], stdin: str | None = None, cwd: pathlib.Path | None = None) tuple[int, str, str]#

Run command.

Parameters:
  • command (str) – Command to execute. Command can not contain spaces.

  • args (list[str]) – List of arguments for command. Argument containing spaces should be wrapped in quotes.

  • stdin (Optional[str]) – Input for command.

  • cwd (Optional[pathlib.Path]) – In which directory the command should be run.

Raises:

ValueError – Command is both running and dead.

Returns:

Tuple with return code, stdout and stderr.

Return type:

tuple[int, str, str]

close() None#

Close any connections runner has.

Return type:

None

__enter__() SshCommandRunner#
Return type:

SshCommandRunner

__exit__(*args: list[Any]) None#
Parameters:

args (list[Any]) –

Return type:

None

__eq__(other: object) bool#
Parameters:

other (object) –

Return type:

bool

__repr__() str#
Return type:

str