Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions device_smi/cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ def __init__(self, cls):
flags = set()

if os.name == 'posix':
if platform.system().lower() == "darwin":
print("eeeeeeeeeee")
print(_run(['sysctl', 'machdep.cpu.features']))
print("eeeeeeeeeee")
elif "virtualization" in _run(["lscpu"]).lower():
cls.virtualized = True
try:
with open("/proc/cpuinfo", "r") as f:
lines = f.readlines()
Expand Down Expand Up @@ -76,19 +82,23 @@ def __init__(self, cls):
break
else:
if platform.system().lower() == "windows":
command_result = _run(["wmic", "cpu", "get", "manufacturer,name,numberofcores,numberoflogicalprocessors", "/format:csv"]).strip()
command_result = re.sub(r'\n+', '\n', command_result) # windows uses \n\n
result = command_result.split("\n")[1].split(",")
command_result = _run(["wmic", "cpu", "get", "manufacturer,name,numberofcores,numberoflogicalprocessors,VirtualizationFirmwareEnabled", "/value"]).strip().lower()
result = self.to_dict(command_result, "=")
command_result = re.sub(r'\n+', '\n', command_result)

cpu_count = command_result.count('\n')
model = result[2].strip()
cpu_cores = int(result[3])
cpu_threads = int(result[4])
vendor = result[1].strip()

command_result = _run(["wmic", "os", "get", "TotalVisibleMemorySize", "/Value", "/format:csv"]).strip()
command_result = re.sub(r'\n+', '\n', command_result)
result = command_result.split("\n")[1].split(",")
mem_total = int(result[1])
model = result['name']
cpu_cores = result['numberofcores']
cpu_threads = result['numberoflogicalprocessors']

vendor = result['manufacturer']

cls.virtualized = result['virtualizationfirmwareenabled'] == "true"

result = self.to_dict(_run(["wmic", "os", "get", "TotalVisibleMemorySize", "/Value"]).strip().strip().lower(), "=")

mem_total = int(result['totalvisiblememorysize'])

model = model.lower()
if "amd" in model:
Expand Down