From 2e531dc7b1cd7d5da9b08ebd0eb49bb9e3eeaf6b Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Wed, 6 Jan 2021 20:56:33 +0000 Subject: [PATCH 1/2] [system-health] Make run_command() Python 3-compliant --- src/system-health/health_checker/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/system-health/health_checker/utils.py b/src/system-health/health_checker/utils.py index fe26054e420..ff2db0c377f 100644 --- a/src/system-health/health_checker/utils.py +++ b/src/system-health/health_checker/utils.py @@ -8,8 +8,8 @@ def run_command(command): :return: Output of the shell command. """ try: - process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE) - return process.communicate()[0].encode('utf-8') + process = subprocess.Popen(command, shell=True, text=True, stdout=subprocess.PIPE) + return process.communicate()[0] except Exception: return None From 7b8b790c29b041320a6d25a0755266c7601ebe1d Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Wed, 6 Jan 2021 21:24:45 +0000 Subject: [PATCH 2/2] Change 'text' to 'universal_newlines' --- src/system-health/health_checker/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/system-health/health_checker/utils.py b/src/system-health/health_checker/utils.py index ff2db0c377f..f310002e1e5 100644 --- a/src/system-health/health_checker/utils.py +++ b/src/system-health/health_checker/utils.py @@ -8,7 +8,7 @@ def run_command(command): :return: Output of the shell command. """ try: - process = subprocess.Popen(command, shell=True, text=True, stdout=subprocess.PIPE) + process = subprocess.Popen(command, shell=True, universal_newlines=True, stdout=subprocess.PIPE) return process.communicate()[0] except Exception: return None