Skip to content

Commit

Permalink
Merge pull request #30756 from basepi/highstate.outputter.23789
Browse files Browse the repository at this point in the history
[2015.8] Fix two error conditions in the highstate outputter
  • Loading branch information
Mike Place committed Feb 1, 2016
2 parents 46adb2d + 16ad24d commit 1f87ad0
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions salt/output/highstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
# Import 3rd-party libs
import salt.ext.six as six

import logging

log = logging.getLogger(__name__)


def output(data):
'''
Expand Down Expand Up @@ -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'])
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1f87ad0

Please sign in to comment.