From: Ondrej Lichtner <olichtne(a)redhat.com>
Instead of returning bytes, just decode the data immediately so that it
can be worked with as before - strings.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Common/ExecCmd.py | 6 ++++--
lnst/Common/GitVersion.py | 2 +-
lnst/Common/Version.py | 2 +-
lnst/Devices/Device.py | 7 +++----
lnst/Slave/InterfaceManager.py | 1 -
5 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/lnst/Common/ExecCmd.py b/lnst/Common/ExecCmd.py
index dff5b16..007acbd 100644
--- a/lnst/Common/ExecCmd.py
+++ b/lnst/Common/ExecCmd.py
@@ -58,6 +58,8 @@ def exec_cmd(cmd, die_on_err=True, log_outputs=True, report_stderr=False, json=F
subp = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, close_fds=True)
(data_stdout, data_stderr) = subp.communicate()
+ data_stdout = data_stdout.decode()
+ data_stderr = data_stderr.decode()
'''
When we should not die on error, do not print anything and let
@@ -65,9 +67,9 @@ def exec_cmd(cmd, die_on_err=True, log_outputs=True, report_stderr=False, json=F
'''
if log_outputs:
if data_stdout:
- log_output(logging.debug, "Stdout", data_stdout.decode())
+ log_output(logging.debug, "Stdout", data_stdout)
if data_stderr:
- log_output(logging.debug, "Stderr", data_stderr.decode())
+ log_output(logging.debug, "Stderr", data_stderr)
if subp.returncode and die_on_err:
err = ExecCmdFail(cmd, subp.returncode, [data_stdout, data_stderr], report_stderr)
logging.error(err)
diff --git a/lnst/Common/GitVersion.py b/lnst/Common/GitVersion.py
index fe088a2..6de3c1e 100644
--- a/lnst/Common/GitVersion.py
+++ b/lnst/Common/GitVersion.py
@@ -30,6 +30,6 @@ def git_version():
cmd = ['git', 'rev-parse', 'HEAD']
try:
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=null)
- return proc.communicate()[0].strip()
+ return proc.communicate()[0].decode().strip()
finally:
os.chdir(cwd)
diff --git a/lnst/Common/Version.py b/lnst/Common/Version.py
index b6a2bc6..c7bacfd 100644
--- a/lnst/Common/Version.py
+++ b/lnst/Common/Version.py
@@ -21,7 +21,7 @@ def __init__(self):
self._version = "14"
if git_version:
- self._version += "-" + git_version().decode()
+ self._version += "-" + git_version()
@property
def version(self):
diff --git a/lnst/Devices/Device.py b/lnst/Devices/Device.py
index 66ed7fc..30deb25 100644
--- a/lnst/Devices/Device.py
+++ b/lnst/Devices/Device.py
@@ -232,18 +232,18 @@ def _vars(self):
def _clear_tc_qdisc(self):
exec_cmd("tc qdisc del dev %s root" % self.name, die_on_err=False)
out, _ = exec_cmd("tc filter show dev %s" % self.name)
- ingress_handles = re.findall("ingress (\\d+):", out.decode())
+ ingress_handles = re.findall("ingress (\\d+):", out)
for ingress_handle in ingress_handles:
exec_cmd("tc qdisc del dev %s handle %s: ingress" %
(self.name, ingress_handle))
out, _ = exec_cmd("tc qdisc show dev %s" % self.name)
- ingress_qdiscs = re.findall("qdisc ingress (\\w+):", out.decode())
+ ingress_qdiscs = re.findall("qdisc ingress (\\w+):", out)
if len(ingress_qdiscs) != 0:
exec_cmd("tc qdisc del dev %s ingress" % self.name)
def _clear_tc_filters(self):
out, _ = exec_cmd("tc filter show dev %s" % self.name)
- egress_prefs = re.findall("pref (\\d+) .* handle", out.decode())
+ egress_prefs = re.findall("pref (\\d+) .* handle", out)
for egress_pref in egress_prefs:
exec_cmd("tc filter del dev %s pref %s" % (self.name, egress_pref))
@@ -631,7 +631,6 @@ def autoneg_off(self):
def _read_adaptive_coalescing(self):
try:
res = exec_cmd("ethtool -c %s" % self.name)
- res = res.decode()
except:
logging.debug("Could not read coalescence values of %s." % self.name)
return (None, None)
diff --git a/lnst/Slave/InterfaceManager.py b/lnst/Slave/InterfaceManager.py
index 7411a73..62f9222 100644
--- a/lnst/Slave/InterfaceManager.py
+++ b/lnst/Slave/InterfaceManager.py
@@ -261,7 +261,6 @@ def _is_name_used(self, name):
out, _ = exec_cmd("ovs-vsctl --columns=name list Interface",
log_outputs=False, die_on_err=False)
- out = out.decode()
for line in out.split("\n"):
m = re.match(r'.*: \"(.*)\"', line)
if m is not None:
--
2.21.0