Support Unicode output for grains.

Closes #12611
This commit is contained in:
Mike Place 2014-06-02 14:43:53 -06:00
parent 968603463b
commit 160d25533a

View File

@ -32,24 +32,24 @@ def output(grains):
colors = salt.utils.get_colors(__opts__.get('color'))
ret = ''
for id_, minion in grains.items():
ret += '{0}{1}{2}:\n'.format(colors['GREEN'], id_, colors['ENDC'])
ret += u'{0}{1}{2}:\n'.format(colors['GREEN'], id_, colors['ENDC'])
for key in sorted(minion):
ret += ' {0}{1}{2}:'.format(colors['CYAN'], key, colors['ENDC'])
ret += u' {0}{1}{2}:'.format(colors['CYAN'], key, colors['ENDC'])
if key == 'cpu_flags':
ret += colors['LIGHT_GREEN']
for val in minion[key]:
ret += ' {0}'.format(val)
ret += u' {0}'.format(val)
ret += '{0}\n'.format(colors['ENDC'])
elif key == 'pythonversion':
ret += ' {0}'.format(colors['LIGHT_GREEN'])
for val in minion[key]:
ret += '{0}.'.format(str(val))
ret += u'{0}.'.format(str(val))
ret = ret[:-1]
ret += '{0}\n'.format(colors['ENDC'])
elif isinstance(minion[key], list):
for val in minion[key]:
ret += '\n {0}{1}{2}'.format(colors['LIGHT_GREEN'], val, colors['ENDC'])
ret += u'\n {0}{1}{2}'.format(colors['LIGHT_GREEN'], val, colors['ENDC'])
ret += '\n'
else:
ret += ' {0}{1}{2}\n'.format(colors['LIGHT_GREEN'], minion[key], colors['ENDC'])
ret += u' {0}{1}{2}\n'.format(colors['LIGHT_GREEN'], minion[key], colors['ENDC'])
return ret