diff options
author | John Kacur <jkacur@redhat.com> | 2022-01-18 15:03:36 -0500 |
---|---|---|
committer | John Kacur <jkacur@redhat.com> | 2022-01-18 15:03:36 -0500 |
commit | 19f9aa600ae331eb2fadf5f821f539bf24f0dea3 (patch) | |
tree | 3a8a7c148573605430d2b6246735cfb97d5fb4c8 | |
parent | 3218c5f39603c4cb6ad8e5caf9fe675f2ea344d1 (diff) | |
download | rteval-19f9aa600ae331eb2fadf5f821f539bf24f0dea3.tar.gz |
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 <jkacur@redhat.com>
-rw-r--r-- | rteval/sysinfo/services.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/rteval/sysinfo/services.py b/rteval/sysinfo/services.py index e5de22e..c85980e 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") |