Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

decode strings to utf-8 #28803

Merged
merged 3 commits into from
Nov 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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