From 83e53cbb915dfea2e05e1a0db1d82fce138279d6 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Thu, 24 Mar 2016 12:37:59 -0700 Subject: [PATCH] Add to_bytes to file paths for accelerate plugin. --- lib/ansible/plugins/connection/accelerate.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ansible/plugins/connection/accelerate.py b/lib/ansible/plugins/connection/accelerate.py index db192a555f..110e2bb2da 100644 --- a/lib/ansible/plugins/connection/accelerate.py +++ b/lib/ansible/plugins/connection/accelerate.py @@ -30,6 +30,7 @@ from ansible.errors import AnsibleError, AnsibleFileNotFound, AnsibleConnectionF from ansible.parsing.utils.jsonify import jsonify from ansible.plugins.connection import ConnectionBase from ansible.utils.encrypt import key_for_hostname, keyczar_encrypt, keyczar_decrypt +from ansible.utils.unicode import to_bytes try: from __main__ import display @@ -210,6 +211,8 @@ class Connection(ConnectionBase): ''' transfer a file from local to remote ''' display.vvv("PUT %s TO %s" % (in_path, out_path), host=self._play_context.remote_addr) + in_path = to_bytes(in_path, errors='strict') + if not os.path.exists(in_path): raise AnsibleFileNotFound("file or module does not exist: %s" % in_path) @@ -262,7 +265,7 @@ class Connection(ConnectionBase): if self.send_data(data): raise AnsibleError("failed to initiate the file fetch with %s" % self._play_context.remote_addr) - fh = open(out_path, "w") + fh = open(to_bytes(out_path, errors='strict'), "w") try: bytes = 0 while True: