Skip to content

Commit

Permalink
[SPARK-8763] backport process.check_output function from Python 2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
cocoatomo committed Jul 1, 2015
1 parent 9765241 commit cf4f901
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions python/run-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@
import Queue
else:
import queue as Queue
if sys.version_info >= (2, 7):
subprocess_check_output = subprocess.check_output
else:
# SPARK-8763
# backported from subprocess module in Python 2.7
def subprocess_check_output(*popenargs, **kwargs):
if 'stdout' in kwargs:
raise ValueError('stdout argument not allowed, it will be overridden.')
process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs)
output, unused_err = process.communicate()
retcode = process.poll()
if retcode:
cmd = kwargs.get("args")
if cmd is None:
cmd = popenargs[0]
raise subprocess.CalledProcessError(retcode, cmd, output=output)
return output


# Append `SPARK_HOME/dev` to the Python path so that we can import the sparktestsupport module
Expand Down Expand Up @@ -156,11 +173,11 @@ def main():

task_queue = Queue.Queue()
for python_exec in python_execs:
python_implementation = subprocess.check_output(
python_implementation = subprocess_check_output(
[python_exec, "-c", "import platform; print(platform.python_implementation())"],
universal_newlines=True).strip()
LOGGER.debug("%s python_implementation is %s", python_exec, python_implementation)
LOGGER.debug("%s version is: %s", python_exec, subprocess.check_output(
LOGGER.debug("%s version is: %s", python_exec, subprocess_check_output(
[python_exec, "--version"], stderr=subprocess.STDOUT, universal_newlines=True).strip())
for module in modules_to_test:
if python_implementation not in module.blacklisted_python_implementations:
Expand Down

0 comments on commit cf4f901

Please sign in to comment.