Skip to content

Commit 19af9e6

Browse files
AtlasPilotPuppyconviva-zz
authored andcommitted
SPARK-1990: added compatibility for python 2.6 for ssh_read command
https://issues.apache.org/jira/browse/SPARK-1990 There were some posts on the lists that spark-ec2 does not work with Python 2.6. In addition, we should check the Python version at the top of the script and exit if it's too old Author: Anant <[email protected]> Closes apache#941 from anantasty/SPARK-1990 and squashes the following commits: 4ca441d [Anant] Implmented check_optput withinthe module to work with python 2.6 c6ed85c [Anant] added compatibility for python 2.6 for ssh_read command
1 parent ebd8138 commit 19af9e6

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

ec2/spark_ec2.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,9 +689,23 @@ def ssh(host, opts, command):
689689
time.sleep(30)
690690
tries = tries + 1
691691

692+
# Backported from Python 2.7 for compatiblity with 2.6 (See SPARK-1990)
693+
def _check_output(*popenargs, **kwargs):
694+
if 'stdout' in kwargs:
695+
raise ValueError('stdout argument not allowed, it will be overridden.')
696+
process = subprocess.Popen(stdout=PIPE, *popenargs, **kwargs)
697+
output, unused_err = process.communicate()
698+
retcode = process.poll()
699+
if retcode:
700+
cmd = kwargs.get("args")
701+
if cmd is None:
702+
cmd = popenargs[0]
703+
raise subprocess.CalledProcessError(retcode, cmd, output=output)
704+
return output
705+
692706

693707
def ssh_read(host, opts, command):
694-
return subprocess.check_output(
708+
return _check_output(
695709
ssh_command(opts) + ['%s@%s' % (opts.user, host), stringify_command(command)])
696710

697711

0 commit comments

Comments
 (0)