From 19f9aa600ae331eb2fadf5f821f539bf24f0dea3 Mon Sep 17 00:00:00 2001 From: John Kacur Date: Tue, 18 Jan 2022 15:03:36 -0500 Subject: [PATCH] rteval: Fix Popen for python3.6 where text=True is not available Fix using text=True in Popen for python-3.6 by using encoding='utf-8' instead Signed-off-by: John Kacur --- rteval/sysinfo/services.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rteval/sysinfo/services.py b/rteval/sysinfo/services.py index e5de22efc342..c85980e19165 100644 --- a/rteval/sysinfo/services.py +++ b/rteval/sysinfo/services.py @@ -62,11 +62,11 @@ class SystemServices: if not [1 for p in reject if fnmatch.fnmatch(servicename, p)] \ and os.access(service, os.X_OK): cmd = '%s -qs "\(^\|\W\)status)" %s' % (getcmdpath('grep'), service) - c = subprocess.Popen(cmd, shell=True, text=True) + c = subprocess.Popen(cmd, shell=True, encoding='utf-8') c.wait() if c.returncode == 0: cmd = ['env', '-i', 'LANG="%s"' % os.environ['LANG'], 'PATH="%s"' % os.environ['PATH'], 'TERM="%s"' % os.environ['TERM'], service, 'status'] - c = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + c = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8') c.wait() if c.returncode == 0 and (c.stdout.read() or c.stderr.read()): ret_services[servicename] = 'running' @@ -81,7 +81,7 @@ class SystemServices: ret_services = {} cmd = '%s list-unit-files -t service --no-legend' % getcmdpath('systemctl') self.__log(Log.DEBUG, "cmd: %s" % cmd) - c = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + c = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8') for p in c.stdout: # p are lines like b'servicename.service status' v = p.strip().split() @@ -91,7 +91,7 @@ class SystemServices: def services_get(self): cmd = [getcmdpath('ps'), '-ocomm=', '1'] - c = subprocess.Popen(cmd, stdout=subprocess.PIPE, text=True) + c = subprocess.Popen(cmd, stdout=subprocess.PIPE, encoding='utf-8') self.__init = c.stdout.read().strip() if self.__init == 'systemd': self.__log(Log.DEBUG, "Using systemd to get services status") -- 2.31.1