Update methods for retrieving CPU core count and CPU configuration

This commit is contained in:
Hoang Hong Quan
2024-08-07 17:28:53 +07:00
parent 2941d784ab
commit 013500db11
2 changed files with 4 additions and 15 deletions

View File

@@ -78,18 +78,13 @@ class AIDA64:
elif "NUC" in motherboard_info["Motherboard Name"]:
motherboard_info["Platform"] = "NUC"
# Count and format CPU configuration
motherboard_info["CPU Configuration"] = str(len(dmi.get("Processors", {}))).zfill(2)
return motherboard_info
def cpu(self, cpu_table):
cpu_info = {}
# Extract CPU Manufacturer
cpu_info["CPU Manufacturer"] = cpu_table.get("CPU Manufacturer", {}).get("Company Name", "Unknown")
# Extract Processor Name
cpu_props = cpu_table.get("CPU Properties", {})
cpu_info["Processor Name"] = cpu_props.get("CPU Type", "Unknown").split(",")[0]
@@ -106,18 +101,12 @@ class AIDA64:
cpu_info["CPU Manufacturer"] = "AMD"
cpu_info["Processor Name"] += cpu_info["CPU Manufacturer"] + processor_name.split(cpu_info["CPU Manufacturer"])[-1]
# Extract CPU Codename
cpu_info["CPU Codename"] = cpu_props.get("CPU Alias", "Unknown")
# Extract CPU Cores count
core_indices = []
for key in list(cpu_table.get("CPU Utilization", {}).keys()):
core_index = key.split("#")[2].split(" ")[0]
if "CPU #1" in key and core_index not in core_indices:
core_indices.append(core_index)
cpu_info["CPU Cores"] = str(len(core_indices)).zfill(2)
cpu_info["CPU Cores"] = str(sum(1 for key in list(cpu_table.get("CPU Utilization", {}).keys()) if not "SMT Unit" in key or "SMT Unit #1" in key)).zfill(2)
cpu_info["CPU Configuration"] = list(cpu_table.get("CPU Utilization", {}).keys())[-1].split(" / ")[0].split("#")[-1].zfill(2)
# Extract Instruction Set
cpu_info["Instruction Set"] = cpu_props.get("Instruction Set", "Unknown")
return cpu_info

View File

@@ -387,7 +387,7 @@ class builder:
hardware_shorc["Motherboard Name"] = hardware["Motherboard"].get("Motherboard Name").upper()
hardware_shorc["Motherboard Chipset"] = hardware["Motherboard"].get("Motherboard Chipset").upper()
hardware_shorc["Platform"] = hardware["Motherboard"].get("Platform")
hardware_shorc["CPU Configuration"] = hardware["Motherboard"].get("CPU Configuration")
hardware_shorc["CPU Configuration"] = hardware["CPU"].get("CPU Configuration")
hardware_shorc["CPU Manufacturer"] = hardware["CPU"].get("CPU Manufacturer")
hardware_shorc["Processor Name"] = hardware["CPU"].get("Processor Name")
hardware_shorc["CPU Cores"] = hardware["CPU"].get("CPU Cores")