Skip to content

Commit 17dc001

Browse files
authored
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.
1 parent 6f768ea commit 17dc001

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

archinstall/lib/hardware.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,18 @@ def loaded_modules(self) -> list[str]:
193193

194194
return modules
195195

196+
@cached_property
197+
def graphics_devices(self) -> dict[str, str]:
198+
"""
199+
Returns detected graphics devices (cached)
200+
"""
201+
cards: dict[str, str] = {}
202+
for line in SysCommand('lspci'):
203+
if b' VGA ' in line or b' 3D ' in line:
204+
_, identifier = line.split(b': ', 1)
205+
cards[identifier.strip().decode('UTF-8')] = str(line)
206+
return cards
207+
196208

197209
_sys_info = _SysInfo()
198210

@@ -209,24 +221,19 @@ def has_uefi() -> bool:
209221

210222
@staticmethod
211223
def _graphics_devices() -> dict[str, str]:
212-
cards: dict[str, str] = {}
213-
for line in SysCommand('lspci'):
214-
if b' VGA ' in line or b' 3D ' in line:
215-
_, identifier = line.split(b': ', 1)
216-
cards[identifier.strip().decode('UTF-8')] = str(line)
217-
return cards
224+
return _sys_info.graphics_devices
218225

219226
@staticmethod
220227
def has_nvidia_graphics() -> bool:
221-
return any('nvidia' in x.lower() for x in SysInfo._graphics_devices())
228+
return any('nvidia' in x.lower() for x in _sys_info.graphics_devices)
222229

223230
@staticmethod
224231
def has_amd_graphics() -> bool:
225-
return any('amd' in x.lower() for x in SysInfo._graphics_devices())
232+
return any('amd' in x.lower() for x in _sys_info.graphics_devices)
226233

227234
@staticmethod
228235
def has_intel_graphics() -> bool:
229-
return any('intel' in x.lower() for x in SysInfo._graphics_devices())
236+
return any('intel' in x.lower() for x in _sys_info.graphics_devices)
230237

231238
@staticmethod
232239
def cpu_vendor() -> CpuVendor | None:

0 commit comments

Comments
 (0)