aboutsummaryrefslogtreecommitdiff
path: root/ec2/spark_ec2.py
diff options
context:
space:
mode:
Diffstat (limited to 'ec2/spark_ec2.py')
-rwxr-xr-xec2/spark_ec2.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/ec2/spark_ec2.py b/ec2/spark_ec2.py
index 52a89cb248..803caa0c48 100755
--- a/ec2/spark_ec2.py
+++ b/ec2/spark_ec2.py
@@ -689,9 +689,23 @@ def ssh(host, opts, command):
time.sleep(30)
tries = tries + 1
+# Backported from Python 2.7 for compatiblity with 2.6 (See SPARK-1990)
+def _check_output(*popenargs, **kwargs):
+ if 'stdout' in kwargs:
+ raise ValueError('stdout argument not allowed, it will be overridden.')
+ process = subprocess.Popen(stdout=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
+
def ssh_read(host, opts, command):
- return subprocess.check_output(
+ return _check_output(
ssh_command(opts) + ['%s@%s' % (opts.user, host), stringify_command(command)])