Merge pull request #28803 from jfindlay/sdecodes

decode strings to utf-8
This commit is contained in:
Mike Place 2015-11-11 21:59:38 -07:00
commit 30ea94439c
3 changed files with 10 additions and 6 deletions

View file

@ -69,7 +69,6 @@ import textwrap
# Import salt libs
import salt.utils
import salt.utils.locales
import salt.output
from salt.utils.locales import sdecode
@ -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'))
@ -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
@ -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)
@ -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
}

View file

@ -37,6 +37,7 @@ from salt.utils import immutabletypes
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
@ -494,6 +495,7 @@ class Compiler(object):
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

View file

@ -252,6 +252,7 @@ import salt.payload
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
@ -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():
@ -2319,7 +2320,7 @@ def recurse(name,
# 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