pyinfra.connectors.local module

The @local connector executes changes on the local machine using subprocesses.

class pyinfra.connectors.local.Meta

Bases: pyinfra.api.connectors.BaseConnectorMeta

handles_execution = True
pyinfra.connectors.local.connect(state, host)
pyinfra.connectors.local.get_file(state, host, remote_filename, filename_or_io, remote_temp_filename=None, print_output=False, print_input=False, **command_kwargs)

Download a local file by copying it to a temporary location and then writing it to our filename or IO object.

pyinfra.connectors.local.put_file(state, host, filename_or_io, remote_filename, remote_temp_filename=None, print_output=False, print_input=False, **command_kwargs)

Upload a local file or IO object by copying it to a temporary directory and then writing it to the upload location.

pyinfra.connectors.local.rsync(state, host, src, dest, flags, print_output=False, print_input=False, **command_kwargs)
pyinfra.connectors.local.run_shell_command(state, host, command, get_pty=False, timeout=None, stdin=None, success_exit_codes=None, print_output=False, print_input=False, return_combined_output=False, **command_kwargs)

Execute a command on the local machine.

  • state (pyinfra.api.State object) – state object for this command
  • host (pyinfra.api.Host object) – the target host
  • command (string) – actual command to execute
  • sudo (boolean) – whether to wrap the command with sudo
  • sudo_user (string) – user to sudo to
  • env (dict) – environment variables to set
  • timeout (int) – timeout for this command to complete before erroring

(exit_code, stdout, stderr) stdout and stderr are both lists of strings from each buffer.

Return type