Skip to content

Commit

Permalink
Implmented check_optput withinthe module to work with python 2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
AtlasPilotPuppy committed Jun 10, 2014
1 parent c6ed85c commit 4ca441d
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions ec2/spark_ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,13 +669,22 @@ def ssh(host, opts, command):
tries = tries + 1


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):
if sys.version_info < (2, 7):
return subprocess.Popen(
ssh_command(opts) + ['%s@%s' %
(opts.user, host), stringify_command(command)],
stdout=subprocess.PIPE).stdout
return subprocess.check_output(
return _check_output(
ssh_command(opts) + ['%s@%s' % (opts.user, host), stringify_command(command)])


Expand Down

0 comments on commit 4ca441d

Please sign in to comment.