pyinfra.api.command module

class pyinfra.api.command.FileDownloadCommand(src: str, dest: str | IO, remote_temp_filename=None, **kwargs: Unpack)

Bases: PyinfraCommand

execute(state: State, host: Host, connector_arguments: ConnectorArguments)
class pyinfra.api.command.FileUploadCommand(src: str | IO, dest: str, remote_temp_filename=None, **kwargs: Unpack)

Bases: PyinfraCommand

execute(state: State, host: Host, connector_arguments: ConnectorArguments)
class pyinfra.api.command.FunctionCommand(function: Callable, args, func_kwargs, **kwargs: Unpack)

Bases: PyinfraCommand

execute(state: State, host: Host, connector_arguments: ConnectorArguments)
class pyinfra.api.command.MaskString

Bases: str

class pyinfra.api.command.PyinfraCommand(**arguments: Unpack)

Bases: object

connector_arguments: ConnectorArguments
execute(state: State, host: Host, connector_arguments: ConnectorArguments)
class pyinfra.api.command.QuoteString(obj: str | StringCommand)

Bases: object

obj: str | StringCommand
class pyinfra.api.command.RsyncCommand(src: str, dest: str, flags, **kwargs: Unpack)

Bases: PyinfraCommand

execute(state: State, host: Host, connector_arguments: ConnectorArguments)
class pyinfra.api.command.StringCommand(*bits, _separator=' ', **arguments: Unpack)

Bases: PyinfraCommand

execute(state: State, host: Host, connector_arguments: ConnectorArguments)
get_masked_value() str
get_raw_value() str
pyinfra.api.command.make_formatted_string_command(string: str, *args, **kwargs) StringCommand

Helper function that takes a shell command or script as a string, splits it using shlex.split and then formats each bit, returning a StringCommand instance with each bit.

Useful to enable string formatted commands/scripts, for example:

curl_command = make_formatted_string_command(
    'curl -sSLf {0} -o {1}',
    QuoteString(src),
    QuoteString(dest),
)