testing/nxdiag: Move to "system" and improve info generated

Move the application to the "System" category. Improve host OS info by using platform.uname() and get current config file using CONFIG_BASE_DEFCONFIG
This commit is contained in:
Lucas Saavedra Vaz 2023-05-26 19:50:04 -03:00 committed by Xiang Xiao
parent df418bea81
commit 9cc710e954
6 changed files with 55 additions and 49 deletions

View file

@ -181,8 +181,7 @@ def get_os_version():
"""
Gets the OS distribution and version. This function works on Linux, Windows,
and macOS. On Linux, if the distro package is installed, it will be used to
get the OS distribution. Otherwise, the platform.system() function will be
used.
get the OS distribution.
Args:
None.
@ -192,24 +191,29 @@ def get_os_version():
"""
os_name = platform.system()
os_version = platform.release()
os_distro = ""
sys_id = ""
if os_name == "Windows":
os_distro = "Windows"
os_version = platform.win32_ver()[0]
sys_id = f"{os_distro} {os_version}"
elif os_name == "Darwin":
os_distro = "macOS"
os_uname = " ".join(platform.uname())
os_version = platform.mac_ver()[0]
sys_id = f"{os_distro} {os_version} {os_uname}"
elif os_name == "Linux":
os_uname = " ".join(platform.uname())
try:
import distro
return distro.name(pretty=True)
sys_id = distro.name(pretty=True) + " " + os_uname
except ImportError:
os_distro = platform.system()
sys_id = os_uname
return f"{os_distro} {os_version}"
return sys_id
def get_compilation_flags(flags):