From 37d6da7e4eb8897dfb80797f28db85ccdd09d376 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 3 Feb 2022 00:26:09 +1100 Subject: Migrate old input to new menu (#874) * Migrate old input to new menu * Fix imports * Remove imports * Update * Fixed import by changing 'import archinstall', to 'from ..menu import Menu' and use Menu() directly * Converted archinstall. to from ..where import . This enables us to use archinstall as a module, a git repository in testing and other things without having to install archinstall as an actual module. Co-authored-by: Daniel Girtler Co-authored-by: Anton Hvornum --- examples/guided.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'examples') diff --git a/examples/guided.py b/examples/guided.py index 45e213df..9cc39c86 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -58,15 +58,16 @@ def ask_user_questions(): will we continue with the actual installation steps. """ + # ref: https://github.com/archlinux/archinstall/pull/831 + # we'll set NTP to true by default since this is also + # the default value specified in the menu options; in + # case it will be changed by the user we'll also update + # the system immediately + archinstall.SysCommand('timedatectl set-ntp true') + global_menu = archinstall.GlobalMenu() global_menu.enable('keyboard-layout') - if not archinstall.arguments.get('ntp', False): - archinstall.arguments['ntp'] = input("Would you like to use automatic time synchronization (NTP) with the default time servers? [Y/n]: ").strip().lower() in ('y', 'yes', '') - if archinstall.arguments['ntp']: - archinstall.log("Hardware time and other post-configuration steps might be required in order for NTP to work. For more information, please check the Arch wiki.", fg="yellow") - archinstall.SysCommand('timedatectl set-ntp true') - # Set which region to download packages from during the installation global_menu.enable('mirror-region') @@ -293,8 +294,9 @@ def perform_installation(mountpoint): installation.log("For post-installation tips, see https://wiki.archlinux.org/index.php/Installation_guide#Post-installation", fg="yellow") if not archinstall.arguments.get('silent'): - choice = input("Would you like to chroot into the newly created installation and perform post-installation configuration? [Y/n] ") - if choice.lower() in ("y", ""): + prompt = 'Would you like to chroot into the newly created installation and perform post-installation configuration?' + choice = archinstall.Menu(prompt, ['yes', 'no'], default_option='yes').run() + if choice == 'yes': try: installation.drop_to_shell() except: -- cgit v1.2.3-54-g00ecf