Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall
diff options
context:
space:
mode:
authorDylan Taylor <dylan@dylanmtaylor.com>2021-06-02 21:00:42 -0400
committerDylan Taylor <dylan@dylanmtaylor.com>2021-06-02 21:00:42 -0400
commitc851a38a9e3e14e8cc9dee63d6531ba33b6bb262 (patch)
treec00a612bafa18c022c9844e2e78f6f73707e0ad5 /archinstall
parentbedc5cd13277e23141fbd1b491e14ffde106d9f5 (diff)
Add additional hardware functions
Diffstat (limited to 'archinstall')
-rw-r--r--archinstall/lib/hardware.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/archinstall/lib/hardware.py b/archinstall/lib/hardware.py
index 6a3b166d..6f05f620 100644
--- a/archinstall/lib/hardware.py
+++ b/archinstall/lib/hardware.py
@@ -107,6 +107,43 @@ def cpu_vendor() -> Optional[str]:
return None
+def cpu_model() -> Optional[str]:
+ cpu_info_raw = SysCommand("lscpu -J")
+ cpu_info = json.loads(b"".join(cpu_info_raw).decode('UTF-8'))['lscpu']
+
+ for info in cpu_info:
+ if info.get('field', None) == "Model name:":
+ return info.get('data', None)
+ return None
+
+
+def sys_vendor() -> Optional[str]:
+ with open(f"/sys/devices/virtual/dmi/id/sys_vendor") as vendor:
+ return vendor.read()
+
+
+def product_name() -> Optional[str]:
+ with open(f"/sys/devices/virtual/dmi/id/product_name") as product:
+ return product.read()
+
+
+def mem_info():
+ # This implementation is from https://stackoverflow.com/a/28161352
+ return dict((i.split()[0].rstrip(':'), int(i.split()[1])) for i in open('/proc/meminfo').readlines())
+
+
+def mem_available() -> Optional[str]:
+ return mem_info()['MemAvailable']
+
+
+def mem_free() -> Optional[str]:
+ return mem_info()['MemFree']
+
+
+def mem_total() -> Optional[str]:
+ return mem_info()['MemTotal']
+
+
def is_vm() -> bool:
try:
# systemd-detect-virt issues a non-zero exit code if it is not on a virtual machine