* Fix #1106

* flake8

* flake8

Co-authored-by: Daniel Girtler <girtler.daniel@gmail.com>
This commit is contained in:
Daniel Girtler 2022-05-02 21:01:50 +10:00 committed by GitHub
parent 48b1001734
commit f00717ff6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 69 additions and 51 deletions

View File

@ -8,7 +8,6 @@ from ..general import SysCommand, secret
from ..hardware import has_uefi from ..hardware import has_uefi
from ..models import NetworkConfiguration from ..models import NetworkConfiguration
from ..storage import storage from ..storage import storage
from ..output import log
from ..profiles import is_desktop_profile from ..profiles import is_desktop_profile
from ..disk import encrypted_partitions from ..disk import encrypted_partitions
@ -277,11 +276,12 @@ class GlobalMenu(GeneralMenu):
if profile and profile.has_prep_function(): if profile and profile.has_prep_function():
namespace = f'{profile.namespace}.py' namespace = f'{profile.namespace}.py'
with profile.load_instructions(namespace=namespace) as imported: with profile.load_instructions(namespace=namespace) as imported:
if not imported._prep_function(): if imported._prep_function():
log(' * Profile\'s preparation requirements was not fulfilled.', fg='red')
exit(1)
return profile return profile
else:
return self._select_profile()
return self._data_store.get('profile', None)
def _create_superuser_account(self): def _create_superuser_account(self):
superusers = ask_for_superuser_account(str(_('Manage superuser accounts: '))) superusers = ask_for_superuser_account(str(_('Manage superuser accounts: ')))

View File

@ -60,7 +60,7 @@ def select_harddrives(preset: List[str] = []) -> List[str]:
return [] return []
def select_driver(options: Dict[str, Any] = AVAILABLE_GFX_DRIVERS, force_ask: bool = False) -> str: def select_driver(options: Dict[str, Any] = AVAILABLE_GFX_DRIVERS) -> str:
""" """
Some what convoluted function, whose job is simple. Some what convoluted function, whose job is simple.
Select a graphics driver from a pre-defined set of popular options. Select a graphics driver from a pre-defined set of popular options.
@ -88,7 +88,6 @@ def select_driver(options: Dict[str, Any] = AVAILABLE_GFX_DRIVERS, force_ask: bo
'For the best compatibility with your Nvidia hardware, you may want to use the Nvidia proprietary driver.\n' 'For the best compatibility with your Nvidia hardware, you may want to use the Nvidia proprietary driver.\n'
) )
if not arguments.get('gfx_driver', None) or force_ask:
title += _('\n\nSelect a graphics driver or leave blank to install all open-source drivers') title += _('\n\nSelect a graphics driver or leave blank to install all open-source drivers')
arguments['gfx_driver'] = Menu(title, drivers).run() arguments['gfx_driver'] = Menu(title, drivers).run()

View File

@ -1,5 +1,6 @@
# A desktop environment selector. # A desktop environment selector.
import archinstall import archinstall
from archinstall import log
is_top_level_profile = True is_top_level_profile = True
@ -38,15 +39,16 @@ __supported__ = [
] ]
def _prep_function(*args, **kwargs): def _prep_function(*args, **kwargs) -> bool:
""" """
Magic function called by the importing installer Magic function called by the importing installer
before continuing any further. It also avoids executing any before continuing any further. It also avoids executing any
other code in this stage. So it's a safe way to ask the user other code in this stage. So it's a safe way to ask the user
for more input before any other installer steps start. for more input before any other installer steps start.
""" """
desktop = archinstall.Menu('Select your desired desktop environment', __supported__, skip=False).run() desktop = archinstall.Menu('Select your desired desktop environment', __supported__).run()
if desktop:
# Temporarily store the selected desktop profile # Temporarily store the selected desktop profile
# in a session-safe location, since this module will get reloaded # in a session-safe location, since this module will get reloaded
# the next time it gets executed. # the next time it gets executed.
@ -60,7 +62,10 @@ def _prep_function(*args, **kwargs):
if hasattr(imported, '_prep_function'): if hasattr(imported, '_prep_function'):
return imported._prep_function() return imported._prep_function()
else: else:
print(f"Deprecated (??): {desktop} profile has no _prep_function() anymore") log(f"Deprecated (??): {desktop} profile has no _prep_function() anymore")
exit(1)
return False
if __name__ == 'desktop': if __name__ == 'desktop':

View File

@ -27,8 +27,9 @@ def _prep_function(*args, **kwargs):
supported_configurations = ['i3-wm', 'i3-gaps'] supported_configurations = ['i3-wm', 'i3-gaps']
desktop = archinstall.Menu('Select your desired configuration', supported_configurations, skip=False).run() desktop = archinstall.Menu('Select your desired configuration', supported_configurations).run()
if desktop:
# Temporarily store the selected desktop profile # Temporarily store the selected desktop profile
# in a session-safe location, since this module will get reloaded # in a session-safe location, since this module will get reloaded
# the next time it gets executed. # the next time it gets executed.

View File

@ -26,16 +26,19 @@ def _prep_function(*args, **kwargs):
Magic function called by the importing installer Magic function called by the importing installer
before continuing any further. before continuing any further.
""" """
if not archinstall.storage.get('_selected_servers', None):
servers = archinstall.Menu( servers = archinstall.Menu(
'Choose which servers to install, if none then a minimal installation wil be done', available_servers, 'Choose which servers to install, if none then a minimal installation wil be done',
available_servers,
preset_values=archinstall.storage.get('_selected_servers', []),
multi=True multi=True
).run() ).run()
if servers:
archinstall.storage['_selected_servers'] = servers archinstall.storage['_selected_servers'] = servers
return True return True
return False
if __name__ == 'server': if __name__ == 'server':
""" """

View File

@ -18,7 +18,9 @@ __packages__ = [
def _check_driver() -> bool: def _check_driver() -> bool:
if "nvidia" in archinstall.storage.get("gfx_driver_packages", None): packages = archinstall.storage.get("gfx_driver_packages", [])
if packages and "nvidia" in packages:
prompt = 'The proprietary Nvidia driver is not supported by Sway. It is likely that you will run into issues, are you okay with that?' prompt = 'The proprietary Nvidia driver is not supported by Sway. It is likely that you will run into issues, are you okay with that?'
choice = archinstall.Menu(prompt, ['yes', 'no'], default_option='no').run() choice = archinstall.Menu(prompt, ['yes', 'no'], default_option='no').run()
if choice == 'no': if choice == 'no':
@ -34,12 +36,16 @@ def _prep_function(*args, **kwargs):
other code in this stage. So it's a safe way to ask the user other code in this stage. So it's a safe way to ask the user
for more input before any other installer steps start. for more input before any other installer steps start.
""" """
archinstall.storage["gfx_driver_packages"] = archinstall.select_driver(force_ask=True) driver = archinstall.select_driver()
if driver:
archinstall.storage["gfx_driver_packages"] = driver
if not _check_driver(): if not _check_driver():
return _prep_function(args, kwargs) return _prep_function(args, kwargs)
return True return True
return False
# Ensures that this code only gets executed if executed # Ensures that this code only gets executed if executed
# through importlib.util.spec_from_file_location("sway", "/somewhere/sway.py") # through importlib.util.spec_from_file_location("sway", "/somewhere/sway.py")

View File

@ -25,12 +25,16 @@ def _prep_function(*args, **kwargs):
for more input before any other installer steps start. for more input before any other installer steps start.
""" """
archinstall.storage["gfx_driver_packages"] = archinstall.select_driver() driver = archinstall.select_driver()
if driver:
archinstall.storage["gfx_driver_packages"] = driver
return True
# TODO: Add language section and/or merge it with the locale selected # TODO: Add language section and/or merge it with the locale selected
# earlier in for instance guided.py installer. # earlier in for instance guided.py installer.
return True return False
# Ensures that this code only gets executed if executed # Ensures that this code only gets executed if executed