Process helper module

class rebasehelper.helpers.process_helper.ProcessHelper[source]

Class for executing subprocesses.

DEV_NULL: str = '/dev/null'
static run_subprocess(cmd, input_file=None, output_file=None, ignore_stderr=False)[source]

Runs the specified command in a subprocess.

Parameters:
  • cmd (iterable) – A sequence of program arguments.

  • input_file (str, BytesIO) – File to read the input from.

  • output_file (str, BytesIO) – File to write the output of the command to.

  • ignore_stderr (bool) – Whether to ignore stderr output.

Returns:

Exit code of the subprocess.

Return type:

int

static run_subprocess_cwd(cmd, cwd=None, input_file=None, output_file=None, ignore_stderr=False, shell=False)[source]

Runs the specified command in a subprocess in a different working directory.

Parameters:
  • cmd (iterable) – A sequence of program arguments.

  • cwd (str) – Working directory for the command.

  • input_file (str, BytesIO) – File to read the input from.

  • output_file (str, BytesIO) – File to write the output of the command to.

  • ignore_stderr (bool) – Whether to ignore stderr output.

  • shell (bool) – Whether to run the command in a shell.

Returns:

Exit code of the subprocess.

Return type:

int

static run_subprocess_cwd_env(cmd, cwd=None, env=None, input_file=None, output_file=None, ignore_stderr=False, shell=False)[source]

Runs the specified command in a subprocess in a different working directory with a redefined environment.

Parameters:
  • cmd (iterable) – A sequence of program arguments.

  • cwd (str) – Working directory for the command.

  • env (dict) – Environment variables for the new process.

  • input_file (str, BytesIO) – File to read the input from.

  • output_file (str, BytesIO) – File to write the output of the command to.

  • ignore_stderr (bool) – Whether to ignore stderr output.

  • shell (bool) – Whether to run the command in a shell.

Returns:

Exit code of the subprocess.

Return type:

int

static run_subprocess_env(cmd, env=None, input_file=None, output_file=None, ignore_stderr=False, shell=False)[source]

Runs the specified command in a subprocess with a redefined environment.

Parameters:
  • cmd (iterable) – A sequence of program arguments.

  • env (dict) – Environment variables for the new process.

  • input_file (str, BytesIO) – File to read the input from.

  • output_file (str, BytesIO) – File to write the output of the command to.

  • ignore_stderr (bool) – Whether to ignore stderr output.

  • shell (bool) – Whether to run the command in a shell.

Returns:

Exit code of the subprocess.

Return type:

int