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
61d01f54
Commit
61d01f54
authored
Feb 17, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show a nicer message when attempting to diff unicode files.
parent
18cbb64f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
lib/ansible/utils/__init__.py
+11
-3
No files found.
lib/ansible/utils/__init__.py
View file @
61d01f54
...
...
@@ -35,6 +35,7 @@ import tty
import
pipes
import
random
import
difflib
import
warnings
VERBOSITY
=
0
...
...
@@ -619,9 +620,16 @@ def make_sudo_cmd(sudo_user, executable, cmd):
prompt
,
sudo_user
,
executable
or
'$SHELL'
,
pipes
.
quote
(
cmd
))
return
(
'/bin/sh -c '
+
pipes
.
quote
(
sudocmd
),
prompt
)
def
get_diff
(
before
_string
,
after_string
):
def
get_diff
(
before
,
after
):
# called by --diff usage in playbook and runner via callbacks
# include names in diffs 'before' and 'after' and do diff -U 10
differ
=
difflib
.
unified_diff
(
before_string
.
split
(
"
\n
"
),
after_string
.
split
(
"
\n
"
),
'before'
,
'after'
,
''
,
''
,
10
)
return
"
\n
"
.
join
(
list
(
differ
))
try
:
with
warnings
.
catch_warnings
():
warnings
.
simplefilter
(
'ignore'
)
differ
=
difflib
.
unified_diff
(
before
.
split
(
"
\n
"
),
after
.
split
(
"
\n
"
),
'before'
,
'after'
,
''
,
''
,
10
)
return
"
\n
"
.
join
(
list
(
differ
))
except
UnicodeDecodeError
:
return
">> the files are different, but the diff library cannot compare unicode strings"
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