pyinfra.connectors.local module

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

class pyinfra.connectors.local.Meta

Bases: BaseConnectorMeta

handles_execution = True
pyinfra.connectors.local.check_can_rsync(host)
pyinfra.connectors.local.connect(state: State, host: Host)
pyinfra.connectors.local.get_file(state: State, host: Host, remote_filename, filename_or_io, remote_temp_filename=None, print_output: bool = False, print_input: bool = 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.make_names_data(_=None)
pyinfra.connectors.local.put_file(state: State, host: Host, filename_or_io, remote_filename, remote_temp_filename=None, print_output: bool = False, print_input: bool = 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: State, host: Host, src, dest, flags, print_output: bool = False, print_input: bool = False, **command_kwargs)
pyinfra.connectors.local.run_shell_command(state: State, host: Host, command, get_pty: bool = False, timeout=None, stdin=None, success_exit_codes=None, print_output: bool = False, print_input: bool = False, return_combined_output: bool = False, **command_kwargs)

Execute a command on the local machine.

Parameters
  • 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
Returns

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

Return type

tuple