Skip to content

Commit

Permalink
Resolve "Allow override of stdin=/dev/null for logger jobs"
Browse files Browse the repository at this point in the history
Closes #477

See merge request EM-Plasma/BuildScripts!415
  • Loading branch information
Matthew Scot Swan authored and jmgate committed Nov 11, 2020
1 parent 866f11c commit 2dc1424
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ def __init__(self, name, log_dir, strm_dir=None, html_file=None, indent=0,
f.write(html_text)

def log(self, msg, cmd, cwd=Path.cwd(), live_stdout=False,
live_stderr=False, return_info=False, verbose=False):
live_stderr=False, return_info=False, verbose=False,
stdin_redirect=True):
"""
Add something to the log. To conserve memory, ``stdout`` and ``stderr``
will be written to the files as it is being generated.
Expand All @@ -239,6 +240,8 @@ def log(self, msg, cmd, cwd=Path.cwd(), live_stdout=False,
anticipate your command producing large ``stdout``/``stderr``
streams that could cause memory issues.
verbose (bool): Print the command before it is executed.
stdin_redirect (bool): Flag to toggle whether or not we redirect
stdin to /dev/null or not (default: True)
Returns:
dict: A dictionary containing `stdout`, `stderr`, and
Expand Down Expand Up @@ -285,7 +288,11 @@ def log(self, msg, cmd, cwd=Path.cwd(), live_stdout=False,
stderr = ''

# Write to stdout/stderr files as text is being returned.
generator = cf.run_cmd_generator(cmd, cwd)
generator = cf.run_cmd_generator(
cmd,
cwd,
stdin_redirect=stdin_redirect,
)
for result in generator:
if result['stdout'] is not None:
if live_stdout:
Expand Down

0 comments on commit 2dc1424

Please sign in to comment.