Open ChengWu-NJ opened 5 years ago
found same kind of bugs with confusion of bytes and string in firewall-check
Please add universal_newlines=True
to Popen in utils.py so that it works without adding b""
.
index e227549..8efe000 100644
--- a/glusterhealth/reports/utils.py
+++ b/glusterhealth/reports/utils.py
@@ -34,7 +34,7 @@ class CommandError(Exception):
def command_output(cmd):
shell = True if isinstance(cmd, str) else False
- p = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=shell)
+ p = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=shell, universal_newlines=True)
out, err = p.communicate()
if p.returncode != 0:
raise CommandError((p.returncode, out.strip(), err.strip()))
Current change is not compatible in Python2.
It seems all report functions were coded to suppose command_output returning bytes.
here is one of errors after modifying command_output to return str:
#########################################
[2019-08-28 07:11:32.421141] E [utils:160:output_error]
Signed-off-by: root greatdolphin@gmail.com
There was a bug in ./glusterhealth/reports/coredump.py: line 21: subprocess returns bytes rather than a string.