Skip to content

Commit

Permalink
Merge pull request #28803 from jfindlay/sdecodes
Browse files Browse the repository at this point in the history
decode strings to utf-8
  • Loading branch information
Mike Place committed Nov 12, 2015
2 parents 59b505f + 1116338 commit 30ea944
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
9 changes: 5 additions & 4 deletions salt/output/highstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@

# Import salt libs
import salt.utils
import salt.utils.locales
import salt.output
from salt.utils.locales import sdecode

Expand All @@ -87,6 +86,8 @@ def output(data):


def _format_host(host, data):
host = sdecode(host)

colors = salt.utils.get_colors(
__opts__.get('color'),
__opts__.get('color_theme'))
Expand Down Expand Up @@ -157,7 +158,7 @@ def _format_host(host, data):
if ret['result'] is None:
hcolor = colors['LIGHT_YELLOW']
tcolor = colors['LIGHT_YELLOW']
comps = tname.split('_|-')
comps = [sdecode(comp) for comp in tname.split('_|-')]
if __opts__.get('state_output', 'full').lower() == 'filter':
# By default, full data is shown for all types. However, return
# data may be excluded by setting state_output_exclude to a
Expand Down Expand Up @@ -234,7 +235,7 @@ def _format_host(host, data):
# but try to continue on errors
pass
try:
comment = salt.utils.locales.sdecode(ret['comment'])
comment = sdecode(ret['comment'])
comment = comment.strip().replace(
u'\n',
u'\n' + u' ' * 14)
Expand Down Expand Up @@ -267,7 +268,7 @@ def _format_host(host, data):
'tcolor': tcolor,
'comps': comps,
'ret': ret,
'comment': comment,
'comment': sdecode(comment),
# This nukes any trailing \n and indents the others.
'colors': colors
}
Expand Down
2 changes: 2 additions & 0 deletions salt/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from salt.template import compile_template, compile_template_str
from salt.exceptions import SaltRenderError, SaltReqTimeoutError, SaltException
from salt.utils.odict import OrderedDict, DefaultOrderedDict
from salt.utils.locales import sdecode

# Import third party libs
# pylint: disable=import-error,no-name-in-module,redefined-builtin
Expand Down Expand Up @@ -494,6 +495,7 @@ def order_chunks(self, chunks):
chunk['order'] = chunk['order'] + chunk.pop('name_order') / 10000.0
if chunk['order'] < 0:
chunk['order'] = cap + 1000000 + chunk['order']
chunk['name'] = sdecode(chunk['name'])
chunks.sort(key=lambda chunk: (chunk['order'], '{0[state]}{0[name]}{0[fun]}'.format(chunk)))
return chunks

Expand Down
5 changes: 3 additions & 2 deletions salt/states/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ def run():
import salt.utils
import salt.utils.templates
import salt.utils.url
from salt.utils.locales import sdecode
from salt.exceptions import CommandExecutionError
from salt.serializers import yaml as yaml_serializer
from salt.serializers import json as json_serializer
Expand Down Expand Up @@ -2082,7 +2083,7 @@ def recurse(name,
recursively removed so that symlink creation can proceed. This
option is usually not needed except in special circumstances.
'''
name = os.path.expanduser(name)
name = os.path.expanduser(sdecode(name))

user = _test_owner(kwargs, user=user)
if salt.utils.is_windows():
Expand Down Expand Up @@ -2319,7 +2320,7 @@ def process_symlinks(filenames, symlinks):
# the file to copy from; it is either a normal file or an
# empty dir(if include_empty==true).

relname = os.path.relpath(fn_, srcpath)
relname = sdecode(os.path.relpath(fn_, srcpath))
if relname.startswith('..'):
continue

Expand Down

0 comments on commit 30ea944

Please sign in to comment.