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)
|
return _sys_info.cpu_info.get('model name', None)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def sys_vendor() -> str:
|
def sys_vendor() -> str | None:
|
||||||
with open('/sys/devices/virtual/dmi/id/sys_vendor') as vendor:
|
try:
|
||||||
return vendor.read().strip()
|
with open('/sys/devices/virtual/dmi/id/sys_vendor') as vendor:
|
||||||
|
return vendor.read().strip()
|
||||||
|
except FileNotFoundError:
|
||||||
|
return None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def product_name() -> str:
|
def product_name() -> str | None:
|
||||||
with open('/sys/devices/virtual/dmi/id/product_name') as product:
|
try:
|
||||||
return product.read().strip()
|
with open('/sys/devices/virtual/dmi/id/product_name') as product:
|
||||||
|
return product.read().strip()
|
||||||
|
except FileNotFoundError:
|
||||||
|
return None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def mem_available() -> int:
|
def mem_available() -> int:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue