From 09acb2862ada15d28818091312e225ff05a33802 Mon Sep 17 00:00:00 2001 From: CSY-ModelCloud Date: Mon, 2 Dec 2024 17:47:30 +0800 Subject: [PATCH] add kernel for unix --- device_smi/os.py | 6 +++--- tests/os.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/device_smi/os.py b/device_smi/os.py index c40a4c9..286de92 100644 --- a/device_smi/os.py +++ b/device_smi/os.py @@ -15,19 +15,19 @@ def __init__(self, cls): if platform.system().lower() == "linux" or platform.system().lower() == "freebsd" or platform.system().lower() == "solaris" or platform.system().lower() == "sunos": release_info = self.to_dict(_run(["cat", "/etc/os-release"]).replace("\"", "").lower(), "=") - cls.name = release_info["name"] + cls.name = release_info["name"].replace("oracle", "").strip() cls.version = release_info["version_id"] match = re.match(r"(\d+\.\d+)", cls.version) if match: cls.version = match.group(1) - cls.arch = _run(["uname", "-m"]).lower() + cls.kernel, cls.arch = _run(["uname", "-mr"]).lower().split() elif platform.system().lower() == "darwin": release_info = self.to_dict(_run(["sw_vers"]).lower()) cls.name = release_info["productname"] cls.version = release_info["productversion"] - cls.arch = _run(["uname", "-m"]).lower() + cls.kernel, cls.arch = _run(["uname", "-mr"]).lower().split() elif platform.system().lower() == "windows": command_result = _run(["wmic", "os", "get", "caption,version", "/format:csv"]).strip() command_result = re.sub(r'\n+', '\n', command_result) # windows uses \n\n diff --git a/tests/os.py b/tests/os.py index da3ad6f..0d91368 100644 --- a/tests/os.py +++ b/tests/os.py @@ -6,4 +6,4 @@ assert dev.type == "os" assert dev.name assert dev.version -assert dev.arch # in ["x86", "x86_64", "aarch64"] +assert dev.arch in ["x86", "x86_64", "aarch64"]