Cache property of graphics_devices (#4007)

* On horrible hardware this makes it so that the "Graphics drivers" section loads directly.
By initializing it with launch instead of on the fly.

* Init after logs

* This cache the property of graphics drivers properly.
Instead of trying to hack early init.
This commit is contained in:
HADEON 2025-12-21 02:22:59 +01:00 committed by GitHub
parent 6f768ea87c
commit 17dc001857
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 9 deletions

View File

@ -193,6 +193,18 @@ class _SysInfo:
return modules
@cached_property
def graphics_devices(self) -> dict[str, str]:
"""
Returns detected graphics devices (cached)
"""
cards: dict[str, str] = {}
for line in SysCommand('lspci'):
if b' VGA ' in line or b' 3D ' in line:
_, identifier = line.split(b': ', 1)
cards[identifier.strip().decode('UTF-8')] = str(line)
return cards
_sys_info = _SysInfo()
@ -209,24 +221,19 @@ class SysInfo:
@staticmethod
def _graphics_devices() -> dict[str, str]:
cards: dict[str, str] = {}
for line in SysCommand('lspci'):
if b' VGA ' in line or b' 3D ' in line:
_, identifier = line.split(b': ', 1)
cards[identifier.strip().decode('UTF-8')] = str(line)
return cards
return _sys_info.graphics_devices
@staticmethod
def has_nvidia_graphics() -> bool:
return any('nvidia' in x.lower() for x in SysInfo._graphics_devices())
return any('nvidia' in x.lower() for x in _sys_info.graphics_devices)
@staticmethod
def has_amd_graphics() -> bool:
return any('amd' in x.lower() for x in SysInfo._graphics_devices())
return any('amd' in x.lower() for x in _sys_info.graphics_devices)
@staticmethod
def has_intel_graphics() -> bool:
return any('intel' in x.lower() for x in SysInfo._graphics_devices())
return any('intel' in x.lower() for x in _sys_info.graphics_devices)
@staticmethod
def cpu_vendor() -> CpuVendor | None: