mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #30756 from basepi/highstate.outputter.23789
[2015.8] Fix two error conditions in the highstate outputter
This commit is contained in:
commit
1f87ad0387
1 changed files with 17 additions and 2 deletions
|
@ -75,6 +75,10 @@ from salt.utils.locales import sdecode
|
|||
# Import 3rd-party libs
|
||||
import salt.ext.six as six
|
||||
|
||||
import logging
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def output(data):
|
||||
'''
|
||||
|
@ -133,7 +137,18 @@ def _format_host(host, data):
|
|||
# Increment result counts
|
||||
rcounts.setdefault(ret['result'], 0)
|
||||
rcounts[ret['result']] += 1
|
||||
rdurations.append(ret.get('duration', 0))
|
||||
rduration = ret.get('duration', 0)
|
||||
try:
|
||||
float(rduration)
|
||||
rdurations.append(rduration)
|
||||
except ValueError:
|
||||
rduration, _, _ = rduration.partition(' ms')
|
||||
try:
|
||||
float(rduration)
|
||||
rdurations.append(rduration)
|
||||
except ValueError:
|
||||
log.error('Cannot parse a float from duration {0}'
|
||||
.format(ret.get('duration', 0)))
|
||||
|
||||
tcolor = colors['GREEN']
|
||||
schanged, ctext = _format_changes(ret['changes'])
|
||||
|
@ -230,7 +245,7 @@ def _format_host(host, data):
|
|||
# be sure that ret['comment'] is utf-8 friendly
|
||||
try:
|
||||
if not isinstance(ret['comment'], six.text_type):
|
||||
ret['comment'] = ret['comment'].decode('utf-8')
|
||||
ret['comment'] = str(ret['comment']).decode('utf-8')
|
||||
except UnicodeDecodeError:
|
||||
# but try to continue on errors
|
||||
pass
|
||||
|
|
Loading…
Add table
Reference in a new issue