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
This commit is contained in:
parent
bca3f4b660
commit
1ef52f56cb
|
|
@ -239,14 +239,20 @@ class SysInfo:
|
|||
return _sys_info.cpu_info.get('model name', None)
|
||||
|
||||
@staticmethod
|
||||
def sys_vendor() -> str:
|
||||
with open('/sys/devices/virtual/dmi/id/sys_vendor') as vendor:
|
||||
return vendor.read().strip()
|
||||
def sys_vendor() -> str | None:
|
||||
try:
|
||||
with open('/sys/devices/virtual/dmi/id/sys_vendor') as vendor:
|
||||
return vendor.read().strip()
|
||||
except FileNotFoundError:
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def product_name() -> str:
|
||||
with open('/sys/devices/virtual/dmi/id/product_name') as product:
|
||||
return product.read().strip()
|
||||
def product_name() -> str | None:
|
||||
try:
|
||||
with open('/sys/devices/virtual/dmi/id/product_name') as product:
|
||||
return product.read().strip()
|
||||
except FileNotFoundError:
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def mem_available() -> int:
|
||||
|
|
|
|||
Loading…
Reference in New Issue