diff options
author | Pierre Guinoiseau <pierre@guinoiseau.eu> | 2017-09-10 06:52:42 +1200 |
---|---|---|
committer | Toshio Kuratomi <a.badger@gmail.com> | 2017-09-09 11:54:53 -0700 |
commit | 4bb52d52b91faa132dd6e759c4e11b5fb17161be (patch) | |
tree | d89ea3b19ccd565eb809f0559b724b1ae62394f3 /lib | |
parent | 5fbe1e2798706bc7388eb76b893ef54026d023be (diff) | |
download | ansible-4bb52d52b91faa132dd6e759c4e11b5fb17161be.tar.gz |
Fix py3 string issue in jail connection plugin (take 2) (#28374)
* Fix py3 string issue in jail connection plugin
(cherry picked from commit 436b173b24dd88ec77e12596fb9403142e6e08fd)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ansible/plugins/connection/jail.py | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/lib/ansible/plugins/connection/jail.py b/lib/ansible/plugins/connection/jail.py index 5e54d95229..ddd8d6b3dc 100644 --- a/lib/ansible/plugins/connection/jail.py +++ b/lib/ansible/plugins/connection/jail.py @@ -28,7 +28,7 @@ import traceback from ansible.compat.six.moves import shlex_quote from ansible.errors import AnsibleError -from ansible.module_utils._text import to_bytes +from ansible.module_utils._text import to_bytes, to_native, to_text from ansible.plugins.connection import ConnectionBase, BUFSIZE try: @@ -82,16 +82,7 @@ class Connection(ConnectionBase): stdout, stderr = p.communicate() - return stdout.split() - - def get_jail_path(self): - p = subprocess.Popen([self.jls_cmd, '-j', to_bytes(self.jail), '-q', 'path'], - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, stderr=subprocess.PIPE) - - stdout, stderr = p.communicate() - # remove \n - return stdout[:-1] + return to_text(stdout, errors='surrogate_or_strict').split() def _connect(self): ''' connect to the jail; nothing to do here ''' @@ -167,7 +158,7 @@ class Connection(ConnectionBase): traceback.print_exc() raise AnsibleError("failed to transfer file %s to %s" % (in_path, out_path)) if p.returncode != 0: - raise AnsibleError("failed to transfer file %s to %s:\n%s\n%s" % (in_path, out_path, stdout, stderr)) + raise AnsibleError("failed to transfer file %s to %s:\n%s\n%s" % (in_path, out_path, to_native(stdout), to_native(stderr))) except IOError: raise AnsibleError("file or module does not exist at: %s" % in_path) @@ -193,7 +184,7 @@ class Connection(ConnectionBase): raise AnsibleError("failed to transfer file %s to %s" % (in_path, out_path)) stdout, stderr = p.communicate() if p.returncode != 0: - raise AnsibleError("failed to transfer file %s to %s:\n%s\n%s" % (in_path, out_path, stdout, stderr)) + raise AnsibleError("failed to transfer file %s to %s:\n%s\n%s" % (in_path, out_path, to_native(stdout), to_native(stderr))) def close(self): ''' terminate the connection; nothing to do here ''' |