libb.run_command

run_command(cmd, workingdir=None, raise_on_error=True, hidearg=None)[source]

Execute a shell command and return output.

Parameters:
  • cmd – Command as string or list of arguments.

  • workingdir (str) – Directory to execute in (optional).

  • raise_on_error (bool) – Raise exception on non-zero return code.

  • hidearg (str) – Argument value to mask in logs (for passwords).

Returns:

Combined stdout and stderr output.

Return type:

bytes

Raises:

Exception – If command fails and raise_on_error is True.

See also

See tests/test_win.py for usage examples.