Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
e88a9e94
Commit
e88a9e94
authored
Jun 08, 2015
by
Toshio Kuratomi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use to_bytes to avoid tracebacks when passed a byte str instead of a unicode string
Fixes #11198
parent
bbfc982d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
2 deletions
+5
-2
lib/ansible/plugins/connections/winrm.py
+5
-2
No files found.
lib/ansible/plugins/connections/winrm.py
View file @
e88a9e94
...
@@ -45,6 +45,7 @@ from ansible.errors import AnsibleError, AnsibleConnectionFailure, AnsibleFileNo
...
@@ -45,6 +45,7 @@ from ansible.errors import AnsibleError, AnsibleConnectionFailure, AnsibleFileNo
from
ansible.plugins.connections
import
ConnectionBase
from
ansible.plugins.connections
import
ConnectionBase
from
ansible.plugins
import
shell_loader
from
ansible.plugins
import
shell_loader
from
ansible.utils.path
import
makedirs_safe
from
ansible.utils.path
import
makedirs_safe
from
ansible.utils.unicode
import
to_bytes
class
Connection
(
ConnectionBase
):
class
Connection
(
ConnectionBase
):
...
@@ -155,7 +156,7 @@ class Connection(ConnectionBase):
...
@@ -155,7 +156,7 @@ class Connection(ConnectionBase):
def
exec_command
(
self
,
cmd
,
tmp_path
,
executable
=
'/bin/sh'
,
in_data
=
None
):
def
exec_command
(
self
,
cmd
,
tmp_path
,
executable
=
'/bin/sh'
,
in_data
=
None
):
super
(
Connection
,
self
)
.
exec_command
(
cmd
,
tmp_path
,
executable
=
executable
,
in_data
=
in_data
)
super
(
Connection
,
self
)
.
exec_command
(
cmd
,
tmp_path
,
executable
=
executable
,
in_data
=
in_data
)
cmd
=
cmd
.
encode
(
'utf-8'
)
cmd
=
to_bytes
(
cmd
)
cmd_parts
=
shlex
.
split
(
cmd
,
posix
=
False
)
cmd_parts
=
shlex
.
split
(
cmd
,
posix
=
False
)
if
'-EncodedCommand'
in
cmd_parts
:
if
'-EncodedCommand'
in
cmd_parts
:
encoded_cmd
=
cmd_parts
[
cmd_parts
.
index
(
'-EncodedCommand'
)
+
1
]
encoded_cmd
=
cmd_parts
[
cmd_parts
.
index
(
'-EncodedCommand'
)
+
1
]
...
@@ -172,7 +173,9 @@ class Connection(ConnectionBase):
...
@@ -172,7 +173,9 @@ class Connection(ConnectionBase):
except
Exception
as
e
:
except
Exception
as
e
:
traceback
.
print_exc
()
traceback
.
print_exc
()
raise
AnsibleError
(
"failed to exec cmd
%
s"
%
cmd
)
raise
AnsibleError
(
"failed to exec cmd
%
s"
%
cmd
)
return
(
result
.
status_code
,
''
,
result
.
std_out
.
encode
(
'utf-8'
),
result
.
std_err
.
encode
(
'utf-8'
))
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
):
def
put_file
(
self
,
in_path
,
out_path
):
super
(
Connection
,
self
)
.
put_file
(
in_path
,
out_path
)
super
(
Connection
,
self
)
.
put_file
(
in_path
,
out_path
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment