API

procrunner.run(command, *, timeout: Optional[float] = None, callback_stderr: Optional[Callable] = None, callback_stdout: Optional[Callable] = None, creationflags: int = 0, environment: Optional[dict[str, str]] = None, environment_override: Optional[dict[str, str]] = None, preexec_fn: Optional[Callable] = None, print_stderr: bool = True, print_stdout: bool = True, raise_timeout_exception: Any = Ellipsis, stdin: Optional[Union[bytes, int]] = None, win32resolve: bool = True, working_directory: Optional[str] = None) → subprocess.CompletedProcess[source]

Run an external process.

File system path objects (PEP-519) are accepted in the command, environment, and working directory arguments.

Parameters:
  • command (array) – Command line to be run, specified as array.
  • timeout – Terminate program execution after this many seconds.
  • stdin – Optional bytestring that is passed to command stdin, or subprocess.DEVNULL to disable stdin.
  • print_stdout (boolean) – Pass stdout through to sys.stdout.
  • print_stderr (boolean) – Pass stderr through to sys.stderr.
  • callback_stdout – Optional function which is called for each stdout line.
  • callback_stderr – Optional function which is called for each stderr line.
  • creationflags – flags that will be passed to subprocess call
  • environment (dict) – The full execution environment for the command.
  • environment_override (dict) – Change environment variables from the current values for command execution.
  • preexec_fn – pre-execution function, will be passed to subprocess call
  • win32resolve (boolean) – If on Windows, find the appropriate executable first. This allows running of .bat, .cmd, etc. files without explicitly specifying their extension.
  • working_directory (string) – If specified, run the executable from within this working directory.
  • raise_timeout_exception (boolean) – Deprecated compatibility flag.
Returns:

The exit code, stdout, stderr (separately, as byte strings) as a subprocess.CompletedProcess object.