Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

give easyblocks the possibility to choose maxhits for run_cmd_qa #1417

Merged
merged 2 commits into from Oct 8, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 3 additions & 5 deletions easybuild/tools/run.py
Expand Up @@ -130,7 +130,7 @@ def run_cmd(cmd, log_ok=True, log_all=False, simple=False, inp=None, regexp=True
return parse_cmd_output(cmd, stdouterr, ec, simple, log_all, log_ok, regexp)


def run_cmd_qa(cmd, qa, no_qa=None, log_ok=True, log_all=False, simple=False, regexp=True, std_qa=None, path=None):
def 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):
"""
Executes a command cmd
- looks for questions and tries to answer based on qa dictionary
Expand Down Expand Up @@ -227,8 +227,6 @@ def check_answers_list(answers):
else:
runLog = None

maxHitCount = 50

try:
p = Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT, stdin=PIPE, close_fds=True, executable="/bin/bash")
except OSError, err:
Expand Down Expand Up @@ -296,7 +294,7 @@ def check_answers_list(answers):
else:
hitCount = 0

if hitCount > maxHitCount:
if hitCount > maxhits:
# explicitly kill the child process before exiting
try:
os.killpg(p.pid, signal.SIGKILL)
Expand All @@ -305,7 +303,7 @@ def check_answers_list(answers):
_log.debug("run_cmd_qa exception caught when killing child process: %s" % err)
_log.debug("run_cmd_qa: full stdouterr: %s" % stdoutErr)
raise EasyBuildError("run_cmd_qa: cmd %s : Max nohits %s reached: end of output %s",
cmd, maxHitCount, stdoutErr[-500:])
cmd, maxhits, stdoutErr[-500:])

# the sleep below is required to avoid exiting on unknown 'questions' too early (see above)
time.sleep(1)
Expand Down