From 11e34d047bdb1f9d1b6852f85779054e57c37c32 Mon Sep 17 00:00:00 2001 From: Colton Myers Date: Fri, 29 Jan 2016 16:11:18 -0700 Subject: [PATCH 1/3] Ensure rdurations are all floats for the highstate outputter --- salt/output/highstate.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/salt/output/highstate.py b/salt/output/highstate.py index 3ddca6725587..792609871ab3 100644 --- a/salt/output/highstate.py +++ b/salt/output/highstate.py @@ -133,7 +133,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']) From 1b5c6a240ce665bb914d71c3755cdbf2c329560a Mon Sep 17 00:00:00 2001 From: Colton Myers Date: Fri, 29 Jan 2016 16:14:30 -0700 Subject: [PATCH 2/3] Handle non-string types in comment This is not supported, but we should convert blindly to string rather that stacktracing the highstate outputter. --- salt/output/highstate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/output/highstate.py b/salt/output/highstate.py index 792609871ab3..acd219a72cc6 100644 --- a/salt/output/highstate.py +++ b/salt/output/highstate.py @@ -241,7 +241,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 From 16ad24d42c1e1b722d8e299fb54d7b68cc7ef26a Mon Sep 17 00:00:00 2001 From: Colton Myers Date: Mon, 1 Feb 2016 11:28:38 -0700 Subject: [PATCH 3/3] Import the logger --- salt/output/highstate.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/salt/output/highstate.py b/salt/output/highstate.py index acd219a72cc6..48b2cd9949d6 100644 --- a/salt/output/highstate.py +++ b/salt/output/highstate.py @@ -75,6 +75,10 @@ # Import 3rd-party libs import salt.ext.six as six +import logging + +log = logging.getLogger(__name__) + def output(data): '''