Blob Blame History Raw
From 69e481e0fc455f75fcfd2dc0fb2d94af0910445f Mon Sep 17 00:00:00 2001
From: Jake Hunsaker <jhunsake@redhat.com>
Date: Mon, 15 Oct 2018 18:02:37 -0400
Subject: [PATCH] [sosnode] Handle bytes conversion in command output

Converts bytes to strings for formatting command output

Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
---
 soscollector/sosnode.py | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/soscollector/sosnode.py b/soscollector/sosnode.py
index c9ae2ef..dd0664e 100644
--- a/soscollector/sosnode.py
+++ b/soscollector/sosnode.py
@@ -138,12 +138,10 @@ class SosNode():
 
     def _fmt_output(self, stdout=None, stderr=None, rc=0):
         '''Formats the returned output from a command into a dict'''
-        c = {}
-        c['status'] = rc
-        if isinstance(stdout, six.string_types):
-            stdout = [str(stdout)]
-        if isinstance(stderr, six.string_types):
-            stderr = [str(stderr)]
+        if isinstance(stdout, (six.string_types, bytes)):
+            stdout = [stdout.decode('utf-8')]
+        if isinstance(stderr, (six.string_types, bytes)):
+            stderr = [stderr.decode('utf-8')]
         if stdout:
             stdout = ''.join(s for s in stdout) or True
         if stderr:
-- 
2.14.4