Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In v2, exec_command should return bytes and the caller will take responsibility for converting to unicode #12853

Merged
merged 1 commit into from
Oct 21, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/ansible/plugins/connection/winrm.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
from ansible.plugins.connection import ConnectionBase
from ansible.plugins import shell_loader
from ansible.utils.path import makedirs_safe
from ansible.utils.unicode import to_bytes, to_unicode
from ansible.utils.unicode import to_bytes, to_unicode, to_str

class Connection(ConnectionBase):
'''WinRM connections over HTTP/HTTPS.'''
Expand Down Expand Up @@ -200,8 +200,8 @@ def exec_command(self, cmd, in_data=None, sudoable=True):
except Exception as e:
traceback.print_exc()
raise AnsibleError("failed to exec cmd %s" % cmd)
result.std_out = to_unicode(result.std_out)
result.std_err = to_unicode(result.std_err)
result.std_out = to_bytes(result.std_out)
result.std_err = to_bytes(result.std_err)
return (result.status_code, result.std_out, result.std_err)

def put_file(self, in_path, out_path):
Expand Down Expand Up @@ -239,7 +239,7 @@ def put_file(self, in_path, out_path):
cmd_parts = self._shell._encode_script(script, as_list=True)
result = self._winrm_exec(cmd_parts[0], cmd_parts[1:])
if result.status_code != 0:
raise IOError(to_unicode(result.std_err))
raise IOError(to_str(result.std_err))
except Exception:
traceback.print_exc()
raise AnsibleError('failed to transfer file to "%s"' % out_path)
Expand Down Expand Up @@ -281,7 +281,7 @@ def fetch_file(self, in_path, out_path):
cmd_parts = self._shell._encode_script(script, as_list=True)
result = self._winrm_exec(cmd_parts[0], cmd_parts[1:])
if result.status_code != 0:
raise IOError(to_unicode(result.std_err))
raise IOError(to_str(result.std_err))
if result.std_out.strip() == '[DIR]':
data = None
else:
Expand Down