[dpdk-dev] [PATCH] autotest: fix for pure python3 environments
Robin Jarry
robin.jarry at 6wind.com
Thu May 7 11:43:40 CEST 2020
Hi Christian,
2020-05-07, Christian Ehrhardt:
> Without this fix in a pure python3 environment this will run into
> issues like:
> ModuleNotFoundError: No module named 'StringIO'
> or later string encoding issues on check_output.
>
> Signed-off-by: Christian Ehrhardt <christian.ehrhardt at canonical.com>
> @@ -45,11 +45,9 @@ def get_numa_nodes():
> def first_cpu_on_node(node_nr):
> cpu_path = glob.glob("/sys/devices/system/node/node%d/cpu*" % node_nr)
> r = re.compile(r"cpu(\d+)")
> - cpu_name = filter(None,
> - map(r.match,
> - map(os.path.basename, cpu_path)
> - )
> - )
> + cpu_name = [_f for _f in map(r.match,
> + list(map(os.path.basename, cpu_path))
> + ) if _f]
Since filter() is not available on Python 3, maybe this function could
be made a little simpler:
def first_cpu_on_node(node_nr):
for fname in os.listdir("/sys/devices/system/node/node%d" % node_nr):
match = re.match(r"cpu(\d+)", fname)
if match:
return int(match.group(1))
raise ValueError("no cpu on node %d" % node_nr)
The rest looks good to me.
--
Robin
More information about the dev
mailing list