Skip to content

Commit 1ef52f5

Browse files
authored
gracefully return "undefined" if DMI is not in sysfs (#3771)
* gracefully return "undefined" if DMI is not in sysfs fixes #3770, in theory * None works too and is consistent with other behaviour * None doesn't *just* work
1 parent bca3f4b commit 1ef52f5

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

archinstall/lib/hardware.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,14 +239,20 @@ def cpu_model() -> str | None:
239239
return _sys_info.cpu_info.get('model name', None)
240240

241241
@staticmethod
242-
def sys_vendor() -> str:
243-
with open('/sys/devices/virtual/dmi/id/sys_vendor') as vendor:
244-
return vendor.read().strip()
242+
def sys_vendor() -> str | None:
243+
try:
244+
with open('/sys/devices/virtual/dmi/id/sys_vendor') as vendor:
245+
return vendor.read().strip()
246+
except FileNotFoundError:
247+
return None
245248

246249
@staticmethod
247-
def product_name() -> str:
248-
with open('/sys/devices/virtual/dmi/id/product_name') as product:
249-
return product.read().strip()
250+
def product_name() -> str | None:
251+
try:
252+
with open('/sys/devices/virtual/dmi/id/product_name') as product:
253+
return product.read().strip()
254+
except FileNotFoundError:
255+
return None
250256

251257
@staticmethod
252258
def mem_available() -> int:

0 commit comments

Comments
 (0)