提交 96ca23d7 编写于 作者: C Cleber Rosa

avocado/utils/cpu.py: more compact implementation of get_cpu_arch()

This shouldn't change the behavior, but is more compact, and at least
for me, is more readable.

And, it happens to make (pure) pylint happier because there aren't
that many 'return' statements.
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 ee49d06e
......@@ -97,28 +97,20 @@ def get_cpu_arch():
"""
Work out which CPU architecture we're running on
"""
cpu_table = [('^cpu.*(RS64|POWER3|Broadband Engine)', 'power'),
('^cpu.*POWER4', 'power4'),
('^cpu.*POWER5', 'power5'),
('^cpu.*POWER6', 'power6'),
('^cpu.*POWER7', 'power7'),
('^cpu.*POWER8', 'power8'),
('^cpu.*PPC970', 'power970'),
('ARM', 'arm'),
('^flags.*:.* lm .*', 'x86_64')]
cpuinfo = _get_cpu_info()
if _list_matches(cpuinfo, '^cpu.*(RS64|POWER3|Broadband Engine)'):
return 'power'
elif _list_matches(cpuinfo, '^cpu.*POWER4'):
return 'power4'
elif _list_matches(cpuinfo, '^cpu.*POWER5'):
return 'power5'
elif _list_matches(cpuinfo, '^cpu.*POWER6'):
return 'power6'
elif _list_matches(cpuinfo, '^cpu.*POWER7'):
return 'power7'
elif _list_matches(cpuinfo, '^cpu.*POWER8'):
return 'power8'
elif _list_matches(cpuinfo, '^cpu.*PPC970'):
return 'power970'
elif _list_matches(cpuinfo, 'ARM'):
return 'arm'
elif _list_matches(cpuinfo, '^flags.*:.* lm .*'):
return 'x86_64'
else:
return 'i386'
for (pattern, arch) in cpu_table:
if _list_matches(cpuinfo, pattern):
return arch
return 'i386'
def cpu_online_list():
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册