Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/user_interaction.py
diff options
context:
space:
mode:
authorAnton Hvornum <anton.feeds+github@gmail.com>2020-09-30 09:11:36 +0000
committerAnton Hvornum <anton.feeds+github@gmail.com>2020-09-30 09:11:36 +0000
commit85fd06fa8a20a1861c9ec0d8e15da954fe5cdd43 (patch)
tree9bcb45341bd95a225800c5c7680c632e4ebff5cd /archinstall/lib/user_interaction.py
parent5a4d68e617ba4e76137db96542ebaeb08acd70cb (diff)
Finalized magic function _prep_function(). Gets returned when a profile is imported through archinstall.select_profile() user-interaction helper function. Asks for additional user-input right away rather than half way into the installation. This makes sure user input is taken care of before starting the installation. Although it complicates the code layout a tiny bit. Profiles need a __name__ and a _prep_function combo in order to be safely executed by select_profile(). select_profile() will not attempt to run or execute the code in any way unless those to conditions are met. In theory :)
Diffstat (limited to 'archinstall/lib/user_interaction.py')
-rw-r--r--archinstall/lib/user_interaction.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py
index 2a797490..4fc6c8d9 100644
--- a/archinstall/lib/user_interaction.py
+++ b/archinstall/lib/user_interaction.py
@@ -1,4 +1,5 @@
from .exceptions import *
+from .profiles import Profile
from .locale_helpers import search_keyboard_layout
## TODO: Some inconsistencies between the selection processes.
@@ -43,6 +44,18 @@ def select_profile(options):
selected_profile = options[options.index(selected_profile)]
else:
RequirementError("Selected profile does not exist.")
+
+ profile = Profile(None, selected_profile)
+ with open(profile.path, 'r') as source:
+ source_data = source.read()
+
+ # Some crude safety checks, make sure the imported profile has
+ # a __name__ check and if so, check if it's got a _prep_function()
+ # we can call to ask for more user input.
+ if '__name__' in source_data and '_prep_function' in source_data
+ with profile.load_instructions() as imported:
+ if hasattr(imported, '_prep_function'):
+ return profile, imported
return selected_profile
raise RequirementError("Selecting profiles require a least one profile to be given as an option.")