Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib
diff options
context:
space:
mode:
authorAnton Hvornum <anton@hvornum.se>2021-09-06 15:55:05 +0200
committerGitHub <noreply@github.com>2021-09-06 15:55:05 +0200
commit81f3ccad40594fa9e8b4b71d4fae48fe459b6e59 (patch)
tree9c6915a162048a52a66fa661b2d9d4a44c6db323 /archinstall/lib
parent40cd8011847e21f5116c49aaff0336a89988eb92 (diff)
parent1030bd19c58d6587c8c49eb015c78e488a49425e (diff)
Merge pull request #615 from conqp/native_cpu_detection
Native cpu detection
Diffstat (limited to 'archinstall/lib')
-rw-r--r--archinstall/lib/hardware.py34
1 files changed, 21 insertions, 13 deletions
diff --git a/archinstall/lib/hardware.py b/archinstall/lib/hardware.py
index 03335e45..56444eeb 100644
--- a/archinstall/lib/hardware.py
+++ b/archinstall/lib/hardware.py
@@ -1,7 +1,7 @@
import json
import os
-import subprocess
-from typing import Optional
+from pathlib import Path
+from typing import Iterator, Optional
from .general import SysCommand
from .networking import list_interfaces, enrich_iface_types
@@ -57,25 +57,33 @@ AVAILABLE_GFX_DRIVERS = {
"VMware / VirtualBox (open-source)": ["mesa", "xf86-video-vmware"],
}
+CPUINFO = Path("/proc/cpuinfo")
+
+
+def cpuinfo() -> Iterator[dict[str, str]]:
+ """Yields information about the CPUs of the system."""
+ cpu = {}
+
+ with CPUINFO.open() as file:
+ for line in file:
+ if not (line := line.strip()):
+ yield cpu
+ cpu = {}
+ continue
+
+ key, value = line.split(":", maxsplit=1)
+ cpu[key.strip()] = value.strip()
+
def has_wifi() -> bool:
return 'WIRELESS' in enrich_iface_types(list_interfaces().values()).values()
def has_amd_cpu() -> bool:
- try:
- return subprocess.check_output("lscpu | grep AMD", shell=True).strip().decode()
- except:
- pass
- return False
-
+ return any(cpu.get("vendor_id") == "AuthenticAMD" for cpu in cpuinfo())
def has_intel_cpu() -> bool:
- try:
- return subprocess.check_output("lscpu | grep Intel", shell=True).strip().decode()
- except:
- pass
- return False
+ return any(cpu.get("vendor_id") == "GenuineIntel" for cpu in cpuinfo())
def has_uefi() -> bool:
return os.path.isdir('/sys/firmware/efi')