From 1552cc82773b28b91a90f5023565538a2eb965bd Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sat, 22 May 2021 20:50:02 +0200 Subject: Re-worked the select_profile() user interaction. It no longer takes options as a parameter, instead it sources the profiles available, prints a curated list but allows for any input that is a valid profile. --- archinstall/lib/user_interaction.py | 14 ++++++-------- examples/guided.py | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index 50c62aa9..503e9a03 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -563,28 +563,26 @@ def select_disk(dict_o_disks): raise DiskError('select_disk() requires a non-empty dictionary of disks to select from.') -def select_profile(options): +def select_profile(): """ Asks the user to select a profile from the `options` dictionary parameter. Usually this is combined with :ref:`archinstall.list_profiles`. - :param options: A `dict` where keys are the profile name, value should be a dict containing profile information. - :type options: dict - :return: The name/dictionary key of the selected profile :rtype: str """ - profiles = sorted(list(options)) + shown_profiles = sorted(list(archinstall.list_profiles(filter_top_level_profiles=True))) + actual_profiles_raw = shown_profiles + sorted([profile for profile in archinstall.list_profiles() if profile not in shown_profiles]) - if len(profiles) >= 1: - for index, profile in enumerate(profiles): + if len(shown_profiles) >= 1: + for index, profile in enumerate(shown_profiles): print(f"{index}: {profile}") print(' -- The above list is a set of pre-programmed profiles. --') print(' -- They might make it easier to install things like desktop environments. --') print(' -- (Leave blank and hit enter to skip this step and continue) --') - selected_profile = generic_select(profiles, 'Enter a pre-programmed profile name if you want to install one: ', options_output=False) + selected_profile = generic_select(actual_profiles_raw, 'Enter a pre-programmed profile name if you want to install one: ', options_output=False) if selected_profile: return Profile(None, selected_profile) else: diff --git a/examples/guided.py b/examples/guided.py index 122f0804..7d033eaf 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -193,7 +193,7 @@ def ask_user_questions(): # Ask for archinstall-specific profiles (such as desktop environments etc) if not archinstall.arguments.get('profile', None): - archinstall.arguments['profile'] = archinstall.select_profile(archinstall.list_profiles(filter_top_level_profiles=True)) + archinstall.arguments['profile'] = archinstall.select_profile() else: archinstall.arguments['profile'] = Profile(installer=None, path=archinstall.arguments['profile']) -- cgit v1.2.3-70-g09d2 From 662ffb05b2dcb0e5a3f134c05a2cea17ea6e8062 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sat, 22 May 2021 20:51:59 +0200 Subject: Fixes docstrings. --- archinstall/lib/user_interaction.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index 503e9a03..59768334 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -565,8 +565,7 @@ def select_disk(dict_o_disks): def select_profile(): """ - Asks the user to select a profile from the `options` dictionary parameter. - Usually this is combined with :ref:`archinstall.list_profiles`. + Asks the user to select a profile from the available profiles. :return: The name/dictionary key of the selected profile :rtype: str -- cgit v1.2.3-70-g09d2 From 1bc218b2e1b4844750dc5573a5db1034c51841c5 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sat, 22 May 2021 20:57:36 +0200 Subject: Forgot an important import. --- archinstall/lib/user_interaction.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index 59768334..0a4cd0f9 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -17,7 +17,7 @@ from .hardware import AVAILABLE_GFX_DRIVERS, has_uefi from .locale_helpers import list_keyboard_languages, verify_keyboard_layout, search_keyboard_layout from .networking import list_interfaces from .output import log -from .profiles import Profile +from .profiles import Profile, list_profiles # TODO: Some inconsistencies between the selection processes. @@ -570,8 +570,8 @@ def select_profile(): :return: The name/dictionary key of the selected profile :rtype: str """ - shown_profiles = sorted(list(archinstall.list_profiles(filter_top_level_profiles=True))) - actual_profiles_raw = shown_profiles + sorted([profile for profile in archinstall.list_profiles() if profile not in shown_profiles]) + shown_profiles = sorted(list(list_profiles(filter_top_level_profiles=True))) + actual_profiles_raw = shown_profiles + sorted([profile for profile in list_profiles() if profile not in shown_profiles]) if len(shown_profiles) >= 1: for index, profile in enumerate(shown_profiles): -- cgit v1.2.3-70-g09d2 From a9efdac61581844e53c80d214ba88b370c2d7ee6 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sat, 22 May 2021 21:00:11 +0200 Subject: Fix issue from language selection. --- examples/guided.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/guided.py b/examples/guided.py index 7d033eaf..a25f1b3b 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -54,13 +54,13 @@ def ask_user_questions(): if not archinstall.arguments.get('sys-language', None) and archinstall.arguments.get('advanced', False): archinstall.arguments['sys-language'] = input("Enter a valid locale (language) for your OS, (Default: en_US): ").strip() archinstall.arguments['sys-encoding'] = input("Enter a valid system default encoding for your OS, (Default: utf-8): ").strip() + archinstall.log("Keep in mind that if you want multiple locales, post configuration is required.", fg="yellow") - if not archinstall.arguments['sys-language']: - archinstall.arguments['sys-language'] = 'en_US' - if not archinstall.arguments['sys-encoding']: - archinstall.arguments['sys-encoding'] = 'utf-8' + if not archinstall.arguments['sys-language']: + archinstall.arguments['sys-language'] = 'en_US' + if not archinstall.arguments['sys-encoding']: + archinstall.arguments['sys-encoding'] = 'utf-8' - archinstall.log("Keep in mind that if you want multiple locales, post configuration is required.", fg="yellow") # Ask which harddrive/block-device we will install to if archinstall.arguments.get('harddrive', None): -- cgit v1.2.3-70-g09d2 From 9ce4370fc72463685e25cabfd3340c92dad276a7 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sat, 22 May 2021 21:00:59 +0200 Subject: Fix issue from language selection. --- examples/guided.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/guided.py b/examples/guided.py index a25f1b3b..cbf30eb3 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -56,9 +56,9 @@ def ask_user_questions(): archinstall.arguments['sys-encoding'] = input("Enter a valid system default encoding for your OS, (Default: utf-8): ").strip() archinstall.log("Keep in mind that if you want multiple locales, post configuration is required.", fg="yellow") - if not archinstall.arguments['sys-language']: + if not archinstall.arguments.get('sys-language', None): archinstall.arguments['sys-language'] = 'en_US' - if not archinstall.arguments['sys-encoding']: + if not archinstall.arguments.get('sys-encoding', None): archinstall.arguments['sys-encoding'] = 'utf-8' -- cgit v1.2.3-70-g09d2