From 0fa52a5424e28ed62ef84bdc92868bbfc434e015 Mon Sep 17 00:00:00 2001 From: Daniel Girtler Date: Mon, 9 May 2022 20:02:48 +1000 Subject: Introduce ctrl+c and other bug fixes (#1152) * Intergrate ctrl+c * stash * Update * Fix profile reset * flake8 Co-authored-by: Daniel Girtler --- profiles/desktop.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'profiles/desktop.py') diff --git a/profiles/desktop.py b/profiles/desktop.py index eaece9f5..e94d3505 100644 --- a/profiles/desktop.py +++ b/profiles/desktop.py @@ -1,6 +1,12 @@ # A desktop environment selector. +from typing import Any, TYPE_CHECKING + import archinstall -from archinstall import log +from archinstall import log, Menu +from archinstall.lib.menu.menu import MenuSelectionType + +if TYPE_CHECKING: + _: Any is_top_level_profile = True @@ -46,23 +52,26 @@ def _prep_function(*args, **kwargs) -> bool: other code in this stage. So it's a safe way to ask the user for more input before any other installer steps start. """ - desktop = archinstall.Menu(str(_('Select your desired desktop environment')), __supported__).run() + choice = Menu(str(_('Select your desired desktop environment')), __supported__).run() + + if choice.type_ != MenuSelectionType.Selection: + return False - if desktop: + if choice.value: # Temporarily store the selected desktop profile # in a session-safe location, since this module will get reloaded # the next time it gets executed. if not archinstall.storage.get('_desktop_profile', None): - archinstall.storage['_desktop_profile'] = desktop + archinstall.storage['_desktop_profile'] = choice.value if not archinstall.arguments.get('desktop-environment', None): - archinstall.arguments['desktop-environment'] = desktop - profile = archinstall.Profile(None, desktop) + archinstall.arguments['desktop-environment'] = choice.value + profile = archinstall.Profile(None, choice.value) # Loading the instructions with a custom namespace, ensures that a __name__ comparison is never triggered. - with profile.load_instructions(namespace=f"{desktop}.py") as imported: + with profile.load_instructions(namespace=f"{choice.value}.py") as imported: if hasattr(imported, '_prep_function'): return imported._prep_function() else: - log(f"Deprecated (??): {desktop} profile has no _prep_function() anymore") + log(f"Deprecated (??): {choice.value} profile has no _prep_function() anymore") exit(1) return False -- cgit v1.2.3-54-g00ecf