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
10750214
Commit
10750214
authored
Oct 01, 2015
by
Toshio Kuratomi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Since Connection.execute_command() returns bytes, deal with the repurcussions here.
parent
e2ae3215
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
6 deletions
+16
-6
lib/ansible/plugins/action/__init__.py
+16
-6
No files found.
lib/ansible/plugins/action/__init__.py
View file @
10750214
...
@@ -28,14 +28,14 @@ import stat
...
@@ -28,14 +28,14 @@ import stat
import
tempfile
import
tempfile
import
time
import
time
from
six
import
string_types
,
iteritems
from
six
import
binary_type
,
text_type
,
iteritems
from
six.moves
import
StringIO
from
six.moves
import
StringIO
from
ansible
import
constants
as
C
from
ansible
import
constants
as
C
from
ansible.errors
import
AnsibleError
,
AnsibleConnectionFailure
from
ansible.errors
import
AnsibleError
,
AnsibleConnectionFailure
from
ansible.executor.module_common
import
modify_module
from
ansible.executor.module_common
import
modify_module
from
ansible.parsing.utils.jsonify
import
jsonify
from
ansible.parsing.utils.jsonify
import
jsonify
from
ansible.utils.unicode
import
to_bytes
from
ansible.utils.unicode
import
to_bytes
,
to_unicode
try
:
try
:
from
__main__
import
display
from
__main__
import
display
...
@@ -479,13 +479,23 @@ class ActionBase:
...
@@ -479,13 +479,23 @@ class ActionBase:
rc
,
stdout
,
stderr
=
self
.
_connection
.
exec_command
(
cmd
,
in_data
=
in_data
,
sudoable
=
sudoable
)
rc
,
stdout
,
stderr
=
self
.
_connection
.
exec_command
(
cmd
,
in_data
=
in_data
,
sudoable
=
sudoable
)
self
.
_display
.
debug
(
"command execution done"
)
self
.
_display
.
debug
(
"command execution done"
)
if
not
isinstance
(
stdout
,
string_types
):
# stdout and stderr may be either a file-like or a bytes object.
out
=
''
.
join
(
stdout
.
readlines
())
# Convert either one to a text type
# Note: when we address non-utf-8 data we'll have to figure out
# a better strategy than errors='strict'. Perhaps pass the
# errors argument into this method so that the caller can decide or
# even make the caller convert to text type so they can choose.
if
isinstance
(
stdout
,
binary_type
):
out
=
to_unicode
(
stdout
,
errors
=
'strict'
)
elif
not
isinstance
(
stdout
,
text_type
):
out
=
to_unicode
(
b
''
.
join
(
stdout
.
readlines
()),
errors
=
'strict'
)
else
:
else
:
out
=
stdout
out
=
stdout
if
not
isinstance
(
stderr
,
string_types
):
if
isinstance
(
stderr
,
binary_type
):
err
=
''
.
join
(
stderr
.
readlines
())
err
=
to_unicode
(
stderr
,
errors
=
'strict'
)
elif
not
isinstance
(
stderr
,
text_type
):
err
=
to_unicode
(
b
''
.
join
(
stderr
.
readlines
()),
errors
=
'strict'
)
else
:
else
:
err
=
stderr
err
=
stderr
...
...
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