jade.utils.run_command.run_command

jade.utils.run_command.run_command(cmd, output=None, cwd=None, num_retries=0, retry_delay_s=2.0, error_strings=None, **kwargs)[source]

Runs a command as a subprocess.

Parameters:
  • cmd (str) – command to run

  • output (dict, default=None) – If a dict is passed then return stdout and stderr as keys.

  • cwd (str, default=None) – Change the working directory to cwd before executing the process.

  • num_retries (int, default=0) – Retry the command on failure this number of times. Return code and output are from the last command execution.

  • retry_delay_s (float, default=2.0) – Number of seconds to delay in between retries.

  • error_strings (None | str) – Skip retries for these known error strings. Requires output to be set.

  • kwargs – Keyword arguments to forward to the subprocess module.

Returns:

  • int – return code from system; usually zero is good, non-zero is error

  • Caution (Capturing stdout and stderr in memory can be hazardous with)

  • long-running processes that output lots of text. In those cases consider

  • running subprocess.Popen with stdout and/or stderr set to a pre-configured

  • file descriptor.