Skip to content

Commit

Permalink
[subprocess_output] Add compatibility layer with datadog_checks_base (D…
Browse files Browse the repository at this point in the history
  • Loading branch information
olivielpeau authored Apr 13, 2018
1 parent 7318fc0 commit bd657de
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions utils/subprocess_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ def get_subprocess_output(command, log, raise_on_empty_output=True):
Run the given subprocess command and return its output. Raise an Exception
if an error occurs.
"""
return subprocess_output(command, raise_on_empty_output)


def subprocess_output(command, raise_on_empty_output):
"""
Run the given subprocess command and return its output. This is a private method
and should not be called directly, use `get_subprocess_output` instead.
"""

# Use tempfile, allowing a larger amount of memory. The subprocess.Popen
# docs warn that the data read is buffered in memory. They suggest not to
Expand All @@ -29,9 +37,6 @@ def get_subprocess_output(command, log, raise_on_empty_output=True):
proc.wait()
stderr_f.seek(0)
err = stderr_f.read()
if err:
log.debug("Error while running {0} : {1}".format(" ".join(command), err))

stdout_f.seek(0)
output = stdout_f.read()

Expand Down

0 comments on commit bd657de

Please sign in to comment.