Blame SOURCES/sos-collector-bytes-conversion.patch

42837f
From 69e481e0fc455f75fcfd2dc0fb2d94af0910445f Mon Sep 17 00:00:00 2001
42837f
From: Jake Hunsaker <jhunsake@redhat.com>
42837f
Date: Mon, 15 Oct 2018 18:02:37 -0400
42837f
Subject: [PATCH] [sosnode] Handle bytes conversion in command output
42837f
42837f
Converts bytes to strings for formatting command output
42837f
42837f
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
42837f
---
42837f
 soscollector/sosnode.py | 10 ++++------
42837f
 1 file changed, 4 insertions(+), 6 deletions(-)
42837f
42837f
diff --git a/soscollector/sosnode.py b/soscollector/sosnode.py
42837f
index c9ae2ef..dd0664e 100644
42837f
--- a/soscollector/sosnode.py
42837f
+++ b/soscollector/sosnode.py
42837f
@@ -138,12 +138,10 @@ class SosNode():
42837f
 
42837f
     def _fmt_output(self, stdout=None, stderr=None, rc=0):
42837f
         '''Formats the returned output from a command into a dict'''
42837f
-        c = {}
42837f
-        c['status'] = rc
42837f
-        if isinstance(stdout, six.string_types):
42837f
-            stdout = [str(stdout)]
42837f
-        if isinstance(stderr, six.string_types):
42837f
-            stderr = [str(stderr)]
42837f
+        if isinstance(stdout, (six.string_types, bytes)):
42837f
+            stdout = [stdout.decode('utf-8')]
42837f
+        if isinstance(stderr, (six.string_types, bytes)):
42837f
+            stderr = [stderr.decode('utf-8')]
42837f
         if stdout:
42837f
             stdout = ''.join(s for s in stdout) or True
42837f
         if stderr:
42837f
-- 
42837f
2.14.4
42837f