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:
authorDaniel <blackrabbit256@gmail.com>2022-02-12 21:47:51 +1100
committerGitHub <noreply@github.com>2022-02-12 11:47:51 +0100
commit003a35be3d908431c25f7fa9d7a7dd6beb8e0fe1 (patch)
treef7a6dd321bed2ff2a17f438847532efb6d1eda97 /archinstall/lib/user_interaction.py
parent16716d94ebf5197f9c4c0e8cbc50709b4e6931ef (diff)
Fix errors on selection of additional packages (#959)
* Fix errors on selection of additional packages * Fix flake8 * Added the new /groups/search/json/?name=x endpoint merged today * Fixed flake8 complaint * Forgot to do json.loads() on the HTTP request result * Update package selection * Fix flake8 Co-authored-by: Daniel Girtler <girtler.daniel@gmail.com> Co-authored-by: Anton Hvornum <anton@hvornum.se>
Diffstat (limited to 'archinstall/lib/user_interaction.py')
-rw-r--r--archinstall/lib/user_interaction.py38
1 files changed, 23 insertions, 15 deletions
diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py
index 202b14a4..66ad3e2a 100644
--- a/archinstall/lib/user_interaction.py
+++ b/archinstall/lib/user_interaction.py
@@ -12,6 +12,8 @@ from collections.abc import Iterable
from typing import List, Any, Optional, Dict, Union, TYPE_CHECKING
# https://stackoverflow.com/a/39757388/929999
+from .menu.text_input import TextInput
+
if TYPE_CHECKING:
from .disk.partition import Partition
@@ -32,6 +34,7 @@ from .translation import Translation
from .disk.validators import fs_types
from .packages.packages import validate_package_list
+
# TODO: These can be removed after the move to simple_menu.py
def get_terminal_height() -> int:
return shutil.get_terminal_size().lines
@@ -390,28 +393,33 @@ def ask_for_audio_selection(desktop :bool = True) -> str:
return selected_audio
-# TODO: Remove? Moved?
-def ask_additional_packages_to_install(packages :List[str] = None) -> List[str]:
+def ask_additional_packages_to_install(pre_set_packages :List[str] = []) -> List[str]:
# Additional packages (with some light weight error handling for invalid package names)
print(_('Only packages such as base, base-devel, linux, linux-firmware, efibootmgr and optional profile packages are installed.'))
print(_('If you desire a web browser, such as firefox or chromium, you may specify it in the following prompt.'))
- while True:
- packages = [p for p in input(
- _('Write additional packages to install (space separated, leave blank to skip): ')
- ).split(' ') if len(p)]
+ def read_packages(already_defined: list = []) -> list:
+ display = ' '.join(already_defined)
+ input_packages = TextInput(
+ _('Write additional packages to install (space separated, leave blank to skip): '),
+ display
+ ).run()
+ return input_packages.split(' ') if input_packages else []
+
+ pre_set_packages = pre_set_packages if pre_set_packages else []
+ packages = read_packages(pre_set_packages)
+ while True:
if len(packages):
# Verify packages that were given
- try:
- print(_("Verifying that additional packages exist (this might take a few seconds)"))
- validate_package_list(packages)
- break
- except RequirementError as e:
- log(e, fg='red')
- else:
- # no additional packages were selected, which we'll allow
- break
+ print(_("Verifying that additional packages exist (this might take a few seconds)"))
+ valid, invalid = validate_package_list(packages)
+
+ if invalid:
+ log(f"Some packages could not be found in the repository: {invalid}", level=logging.WARNING, fg='red')
+ packages = read_packages(valid)
+ continue
+ break
return packages