easybuild.tools.run module

Tools to run commands.

author:Stijn De Weirdt (Ghent University)
author:Dries Verdegem (Ghent University)
author:Kenneth Hoste (Ghent University)
author:Pieter De Baets (Ghent University)
author:Jens Timmerman (Ghent University)
author:Toon Willems (Ghent University)
author:Ward Poelmans (Ghent University)
easybuild.tools.run.parse_cmd_output(cmd, stdouterr, ec, simple, log_all, log_ok, regexp)

Parse command output and construct return value. :param cmd: executed command :param stdouterr: combined stdout/stderr of executed command :param ec: exit code of executed command :param simple: if True, just return True/False to indicate success, else return a tuple: (output, exit_code) :param log_all: always log command output and exit code :param log_ok: only run output/exit code for failing commands (exit code non-zero) :param regex: regex used to check the output for errors; if True it will use the default (see parse_log_for_error)

easybuild.tools.run.parse_log_for_error(txt, regExp=None, stdout=True, msg=None)

txt is multiline string. - in memory regExp is a one-line regular expression - default

easybuild.tools.run.run_cmd(cmd, *args, **kwargs)

Run specified command (in a subshell) :param cmd: command to run :param log_ok: only run output/exit code for failing commands (exit code non-zero) :param log_all: always log command output and exit code :param simple: if True, just return True/False to indicate success, else return a tuple: (output, exit_code) :param inp: the input given to the command via stdin :param regex: regex used to check the output for errors; if True it will use the default (see parse_log_for_error) :param log_output: indicate whether all output of command should be logged to a separate temporary logfile :param path: path to execute the command in; current working directory is used if unspecified :param force_in_dry_run: force running the command during dry run :param verbose: include message on running the command in dry run output :param shell: allow commands to not run in a shell (especially useful for cmd lists) :param trace: print command being executed as part of trace output

easybuild.tools.run.run_cmd_cache(func)

Function decorator to cache (and retrieve cached) results of running commands.

easybuild.tools.run.run_cmd_qa(cmd, qa, no_qa=None, log_ok=True, log_all=False, simple=False, regexp=True, std_qa=None, path=None, maxhits=50, trace=True)

Run specified interactive command (in a subshell) :param cmd: command to run :param qa: dictionary which maps question to answers :param no_qa: list of patters that are not questions :param log_ok: only run output/exit code for failing commands (exit code non-zero) :param log_all: always log command output and exit code :param simple: if True, just return True/False to indicate success, else return a tuple: (output, exit_code) :param regex: regex used to check the output for errors; if True it will use the default (see parse_log_for_error) :param std_qa: dictionary which maps question regex patterns to answers :param path: path to execute the command is; current working directory is used if unspecified :param maxhits: maximum number of cycles (seconds) without being able to find a known question :param trace: print command being executed as part of trace output