Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Hvornum <anton.feeds+github@gmail.com>2020-10-18 10:03:26 +0200
committerAnton Hvornum <anton.feeds+github@gmail.com>2020-10-18 10:03:26 +0200
commitea84565f8636c0f393e336dbbc93c15cfdba6895 (patch)
tree059f08eead31f7ca3c90e5836633a4a839612dd6
parent1a10fe3f51f7555bf8c29046c707719d7dccb33c (diff)
Implementing error handling for #50. So that the errors do not come at the very end, but in the beginning right after the user inputted something (quicker feedback to the user).
-rw-r--r--examples/guided.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/examples/guided.py b/examples/guided.py
index dcc8279c..83eeabe3 100644
--- a/examples/guided.py
+++ b/examples/guided.py
@@ -53,6 +53,7 @@ archinstall.set_keyboard_language(keyboard_language)
# Set which region to download packages from during the installation
mirror_regions = archinstall.select_mirror_regions(archinstall.list_mirrors())
+# Ask which harddrive/block-device we will install to
harddrive = archinstall.select_disk(archinstall.all_disks())
while (disk_password := getpass.getpass(prompt='Enter disk encryption password (leave blank for no encryption): ')):
disk_password_verification = getpass.getpass(prompt='And one more time for verification: ')
@@ -61,9 +62,11 @@ while (disk_password := getpass.getpass(prompt='Enter disk encryption password (
continue
break
+# Ask for a hostname
hostname = input('Desired hostname for the installation: ')
if len(hostname) == 0: hostname = 'ArchInstall'
+# Ask for a root password (optional, but triggers requirement for super-user if skipped)
while (root_pw := getpass.getpass(prompt='Enter root password (leave blank to leave root disabled): ')):
root_pw_verification = getpass.getpass(prompt='And one more time for verification: ')
if root_pw != root_pw_verification:
@@ -71,6 +74,7 @@ while (root_pw := getpass.getpass(prompt='Enter root password (leave blank to le
continue
break
+# Ask for additional users (super-user if root pw was not set)
users = {}
new_user_text = 'Any additional users to install (leave blank for no users): '
if len(root_pw.strip()) == 0:
@@ -92,6 +96,7 @@ while 1:
users[new_user] = new_user_passwd
break
+# Ask for archinstall-specific profiles (such as desktop environments etc)
while 1:
profile = archinstall.select_profile(archinstall.list_profiles())
if type(profile) != str: # Got a imported profile
@@ -103,7 +108,19 @@ while 1:
else:
break
-packages = input('Additional packages aside from base (space separated): ').split(' ')
+# Additional packages (with some light weight error handling for invalid package names)
+while 1:
+ packages = [package for package in input('Additional packages aside from base (space separated): ').split(' ') if len(package)]
+
+ try:
+ if packages and archinstall.validate_package_list(packages):
+ break
+ except RequirementError as e:
+ print(e)
+
+# TODO: Print a summary here of all the options chosen.
+# Ideally, archinstall should keep track of this internally
+# and there should be something like print(archinstall.config).
"""
Issue a final warning before we continue with something un-revertable.