Fix paramiko's exec_command() to return bytes on python3 (#17372)

* Fix paramiko's exec_command() to return bytes on python3

* Run test_connection for python3 now too

* Fix atomic_move for problem in shippable's testing

* Python-2.4 needs to use b()
This commit is contained in:
Toshio Kuratomi 2016-09-02 20:32:14 -07:00 committed by GitHub
parent 3b2830818e
commit f7b22a5eaa
3 changed files with 13 additions and 13 deletions

View file

@ -40,6 +40,7 @@ from binascii import hexlify
from ansible.compat.six import iteritems
from ansible import constants as C
from ansible.compat.six.moves import input
from ansible.errors import AnsibleError, AnsibleConnectionFailure, AnsibleFileNotFound
from ansible.plugins.connection import ConnectionBase
from ansible.utils.path import makedirs_safe
@ -100,7 +101,7 @@ class MyAddPolicy(object):
fingerprint = hexlify(key.get_fingerprint())
ktype = key.get_name()
inp = raw_input(AUTHENTICITY_MSG % (hostname, ktype, fingerprint))
inp = input(AUTHENTICITY_MSG % (hostname, ktype, fingerprint))
sys.stdin = old_stdin
self.connection.connection_unlock()
@ -274,9 +275,9 @@ class Connection(ConnectionBase):
cmd = to_bytes(cmd, errors='strict')
no_prompt_out = ''
no_prompt_err = ''
become_output = ''
no_prompt_out = b''
no_prompt_err = b''
become_output = b''
try:
chan.exec_command(cmd)
@ -317,8 +318,8 @@ class Connection(ConnectionBase):
except socket.timeout:
raise AnsibleError('ssh timed out waiting for privilege escalation.\n' + become_output)
stdout = ''.join(chan.makefile('rb', bufsize))
stderr = ''.join(chan.makefile_stderr('rb', bufsize))
stdout = b''.join(chan.makefile('rb', bufsize))
stderr = b''.join(chan.makefile_stderr('rb', bufsize))
return (chan.recv_exit_status(), no_prompt_out + stdout, no_prompt_out + stderr)