|
31 | 31 | import Queue |
32 | 32 | else: |
33 | 33 | import queue as Queue |
| 34 | +if sys.version_info >= (2, 7): |
| 35 | + subprocess_check_output = subprocess.check_output |
| 36 | +else: |
| 37 | + # SPARK-8763 |
| 38 | + # backported from subprocess module in Python 2.7 |
| 39 | + def subprocess_check_output(*popenargs, **kwargs): |
| 40 | + if 'stdout' in kwargs: |
| 41 | + raise ValueError('stdout argument not allowed, it will be overridden.') |
| 42 | + process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs) |
| 43 | + output, unused_err = process.communicate() |
| 44 | + retcode = process.poll() |
| 45 | + if retcode: |
| 46 | + cmd = kwargs.get("args") |
| 47 | + if cmd is None: |
| 48 | + cmd = popenargs[0] |
| 49 | + raise subprocess.CalledProcessError(retcode, cmd, output=output) |
| 50 | + return output |
34 | 51 |
|
35 | 52 |
|
36 | 53 | # Append `SPARK_HOME/dev` to the Python path so that we can import the sparktestsupport module |
@@ -156,11 +173,11 @@ def main(): |
156 | 173 |
|
157 | 174 | task_queue = Queue.Queue() |
158 | 175 | for python_exec in python_execs: |
159 | | - python_implementation = subprocess.check_output( |
| 176 | + python_implementation = subprocess_check_output( |
160 | 177 | [python_exec, "-c", "import platform; print(platform.python_implementation())"], |
161 | 178 | universal_newlines=True).strip() |
162 | 179 | LOGGER.debug("%s python_implementation is %s", python_exec, python_implementation) |
163 | | - LOGGER.debug("%s version is: %s", python_exec, subprocess.check_output( |
| 180 | + LOGGER.debug("%s version is: %s", python_exec, subprocess_check_output( |
164 | 181 | [python_exec, "--version"], stderr=subprocess.STDOUT, universal_newlines=True).strip()) |
165 | 182 | for module in modules_to_test: |
166 | 183 | if python_implementation not in module.blacklisted_python_implementations: |
|
0 commit comments