Skip to content

Commit

Permalink
add kernel for unix
Browse files Browse the repository at this point in the history
  • Loading branch information
CSY-ModelCloud committed Dec 2, 2024
1 parent 02128c3 commit 09acb28
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions device_smi/os.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/os.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

0 comments on commit 09acb28

Please sign in to comment.