dav_tools.commands

External command execution on local machine.

Functions

execute(command[, stdin, stdout, stderr])

Run a command.

get_output(command[, on_success, on_error, stdin, stderr])

Run a command and return its output.

is_installed(command)

Check if a command is installed on the system.

Module Contents

dav_tools.commands.execute(command, stdin=_sys.stdin, stdout=_sys.stdout, stderr=_sys.stderr)

Run a command.

Parameters:
  • command (str) – the command to execute

  • stdin – input redirection

  • stdout – output redirection

  • stderr – error redirection

Returns:

True if the command exits with return code zero, False otherwise

Return type:

bool

dav_tools.commands.get_output(command, on_success=lambda x: ..., on_error=None, stdin=_sys.stdin, stderr=_sys.stderr)

Run a command and return its output.

Parameters:
  • command (str) – the command to execute

  • on_success (Callable[[bytes], Any]) – call the specified function on the output before returning the data. Useful for casting the output from its original bytes format

  • on_error (Callable[[], Any] | None) – call the specified function if the command raised an exception. If this value is None, raises the exception.

  • stdin – input redirection

  • stderr – error redirection

Return type:

Any

dav_tools.commands.is_installed(command)

Check if a command is installed on the system.

Parameters:

command (str) – the command to check

Returns:

True if the command is installed, False otherwise

Return type:

bool