From 839e945b87ec16129c201f731da8be12bebe6cb8 Mon Sep 17 00:00:00 2001 From: SecondThundeR Date: Fri, 23 Apr 2021 01:03:34 +0300 Subject: Moved output about base installed packages This prevents screen from being cluttered if the user enters the wrong package(or packages), allowing only repetitions of prompt to be displayed --- examples/guided.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/guided.py b/examples/guided.py index 2bf911fc..cc9cf5fc 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -195,10 +195,10 @@ def ask_user_questions(): archinstall.arguments['audio'] = None # 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: if not archinstall.arguments.get('packages', None): - 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.") archinstall.arguments['packages'] = [package for package in input('Write additional packages to install (space separated, leave blank to skip): ').split(' ') if len(package)] if len(archinstall.arguments['packages']): -- cgit v1.2.3-54-g00ecf From 2d3d3c54ef5ec5f4311afe75d87733a27b1d7509 Mon Sep 17 00:00:00 2001 From: SecondThundeR Date: Fri, 23 Apr 2021 01:08:38 +0300 Subject: Remove unnecessary else in try...except This change simplifies the try...except block in generic_select by adding a break to the item selection by index --- archinstall/lib/user_interaction.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index dcb51e2a..572acf4f 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -277,7 +277,7 @@ def generic_select(options, input_text="Select one of the above by index or abso print(f"{index}: {option}") # The new changes introduce a single while loop for all inputs processed by this function - # Now the try...except...else block handles validation for invalid input from the user + # Now the try...except block handles validation for invalid input from the user while True: try: selected_option = input(input_text) @@ -293,6 +293,7 @@ def generic_select(options, input_text="Select one of the above by index or abso if selected_option >= len(options): raise RequirementError(f'Selected option "{selected_option}" is out of range') selected_option = options[selected_option] + break elif selected_option in options: break # We gave a correct absolute value else: @@ -300,8 +301,6 @@ def generic_select(options, input_text="Select one of the above by index or abso except RequirementError as err: log(f" * {err} * ", fg='red') continue - else: - break return selected_option -- cgit v1.2.3-54-g00ecf From f5b6e7bafead1f604c27bfb31b84f3f560a682c8 Mon Sep 17 00:00:00 2001 From: SecondThundeR Date: Fri, 23 Apr 2021 01:55:53 +0300 Subject: Update logging for some functions - Unified view of warning (red) and info (yellow) logs - Fixed some PEP8 related issues, like removing redundant f-strings and replacing double quotes to single ones - Removed warning logging level for simple logs - Removed other background color settings for logs to fully close https://github.com/archlinux/archinstall/pull/171 --- archinstall/lib/disk.py | 4 ++-- archinstall/lib/installer.py | 10 +++++----- archinstall/lib/mirrors.py | 2 +- archinstall/lib/output.py | 4 ++-- archinstall/lib/user_interaction.py | 25 +++++++++--------------- examples/guided.py | 39 +++++++++++++++++++------------------ 6 files changed, 39 insertions(+), 45 deletions(-) diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index bada4076..de93556a 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -128,7 +128,7 @@ class BlockDevice(): @property def uuid(self): - log(f'BlockDevice().uuid is untested!', level=LOG_LEVELS.Warning, fg='yellow') + log('BlockDevice().uuid is untested!', level=LOG_LEVELS.Warning, fg='yellow') """ Returns the disk UUID as returned by lsblk. This is more reliable than relying on /dev/disk/by-partuuid as @@ -292,7 +292,7 @@ class Partition(): raise DiskError(f"Attempting to encrypt a partition that was not marked for encryption: {self}") if not self.safe_to_format(): - log(f"Partition {self} was marked as protected but encrypt() was called on it!", level=LOG_LEVELS.Error, fg="red") + log(f" * Partition {self} was marked as protected but encrypt() was called on it! * ", level=LOG_LEVELS.Error, fg='red') return False handle = luks2(self, None, None) diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 758033a7..c64079f6 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -79,14 +79,14 @@ class Installer(): self.genfstab() if not (missing_steps := self.post_install_check()): - self.log('Installation completed without any errors. You may now reboot.', bg='black', fg='green', level=LOG_LEVELS.Info) + self.log('Installation completed without any errors. You may now reboot.', fg='green', level=LOG_LEVELS.Info) self.sync_log_to_install_medium() return True else: - self.log('Some required steps were not successfully installed/configured before leaving the installer:', bg='black', fg='red', level=LOG_LEVELS.Warning) + self.log('Some required steps were not successfully installed/configured before leaving the installer:', fg='red', level=LOG_LEVELS.Warning) for step in missing_steps: - self.log(f' - {step}', bg='black', fg='red', level=LOG_LEVELS.Warning) + self.log(f' - {step}', fg='red', level=LOG_LEVELS.Warning) self.log(f"Detailed error logs can be found at: {storage['LOG_PATH']}", level=LOG_LEVELS.Warning) self.log(f"Submit this zip file as an issue to https://github.com/archlinux/archinstall/issues", level=LOG_LEVELS.Warning) @@ -168,7 +168,7 @@ class Installer(): return True else: self.log( - f"Time zone {zone} does not exist, continuing with system default.", + f" * Timezone \"{zone}\" does not exist, continuing with system default * ", level=LOG_LEVELS.Warning, fg='red' ) @@ -460,5 +460,5 @@ class Installer(): vconsole.write(f'KEYMAP={language}\n') vconsole.write(f'FONT=lat9w-16\n') else: - self.log(f'Keyboard language was not changed from default (no language specified).', fg="yellow", level=LOG_LEVELS.Info) + self.log('Keyboard language was not changed from default (no language specified).', fg='yellow', level=LOG_LEVELS.Info) return True diff --git a/archinstall/lib/mirrors.py b/archinstall/lib/mirrors.py index 04f47c0d..57271bf8 100644 --- a/archinstall/lib/mirrors.py +++ b/archinstall/lib/mirrors.py @@ -79,7 +79,7 @@ def list_mirrors(): try: response = urllib.request.urlopen(url) except urllib.error.URLError as err: - log(f'Could not fetch an active mirror-list: {err}', level=LOG_LEVELS.Warning, fg="yellow") + log(f"Could not fetch an active mirror-list: {err}", level=LOG_LEVELS.Warning, fg='yellow') return regions diff --git a/archinstall/lib/output.py b/archinstall/lib/output.py index 6b184b4b..eb23faf4 100644 --- a/archinstall/lib/output.py +++ b/archinstall/lib/output.py @@ -100,12 +100,12 @@ def log(*args, **kwargs): Path(absolute_logfile).parents[0].mkdir(exist_ok=True, parents=True) except PermissionError: # Fallback to creating the log file in the current folder - err_string = f"Not enough permission to place log file at {absolute_logfile}, creating it in {Path('./').absolute()/filename} instead." + err_string = f" * Not enough permission to place log file at {absolute_logfile}, creating it in {Path('./').absolute()/filename} instead * " absolute_logfile = Path('./').absolute()/filename absolute_logfile.parents[0].mkdir(exist_ok=True) absolute_logfile = str(absolute_logfile) storage['LOG_PATH'] = './' - log(err_string, fg="red") + log(err_string, fg='red') Path(absolute_logfile).touch() # Overkill? diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index 572acf4f..ec6b6d34 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -22,11 +22,7 @@ def get_longest_option(options): def check_for_correct_username(username): if re.match(r'^[a-z_][a-z0-9_-]*\$?$', username) and len(username) <= 32: return True - log( - "The username you entered is invalid. Try again", - level=LOG_LEVELS.Warning, - fg='red' - ) + log(' * The username you entered is invalid. Try again * ', fg='red') return False def do_countdown(): @@ -138,8 +134,7 @@ def ask_for_a_timezone(): return timezone else: log( - f"Specified timezone {timezone} does not exist.", - level=LOG_LEVELS.Warning, + f"* Specified timezone {timezone} does not exist * ", fg='red' ) @@ -185,8 +180,7 @@ def ask_to_configure_network(): break except ValueError: log( - "You need to enter a valid IP in IP-config mode.", - level=LOG_LEVELS.Warning, + 'You need to enter a valid IP in IP-config mode', fg='red' ) @@ -201,8 +195,7 @@ def ask_to_configure_network(): break except ValueError: log( - "You need to enter a valid gateway (router) IP address.", - level=LOG_LEVELS.Warning, + 'You need to enter a valid gateway (router) IP address', fg='red' ) @@ -258,15 +251,15 @@ def generic_select(options, input_text="Select one of the above by index or abso # Checking if options are different from `list` or `dict` if type(options) not in [list, dict]: log(f" * Generic select doesn't support ({type(options)}) as type of options * ", fg='red') - log(" * If problem persists, please create an issue on https://github.com/archlinux/archinstall/issues * ", fg='yellow') + log('If problem persists, please create an issue on https://github.com/archlinux/archinstall/issues', fg='yellow') raise RequirementError("generic_select() requires list or dictionary as options.") # To allow only `list` and `dict`, converting values of options here. # Therefore, now we can only provide the dictionary itself if type(options) == dict: options = list(options.values()) if sort: options = sorted(options) # As we pass only list and dict (converted to list), we can skip converting to list if len(options) == 0: - log(f" * Generic select didn't find any options to choose from * ", fg='red') - log(" * If problem persists, please create an issue on https://github.com/archlinux/archinstall/issues * ", fg='yellow') + log(' * Generic select didn\'t find any options to choose from * ', fg='red') + log('If problem persists, please create an issue on https://github.com/archlinux/archinstall/issues', fg='yellow') raise RequirementError('generic_select() requires at least one option to proceed.') @@ -398,7 +391,7 @@ def select_language(options, show_only_country_codes=True): new_options = list(search_keyboard_layout(filter_string)) if len(new_options) <= 0: - log(f"Search string '{filter_string}' yielded no results, please try another search.", fg='yellow') + log(f"Search string '{filter_string}' yielded no results, please try another search", fg='yellow') continue return select_language(new_options, show_only_country_codes=False) @@ -411,7 +404,7 @@ def select_language(options, show_only_country_codes=True): elif verify_keyboard_layout(selected_language): return selected_language else: - log(" * Given language wasn't found * ", fg='red') + log(' * Given language was not found * ', fg='red') raise RequirementError("Selecting languages require a least one language to be given as an option.") diff --git a/examples/guided.py b/examples/guided.py index cc9cf5fc..f89efa45 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -4,7 +4,7 @@ from archinstall.lib.hardware import hasUEFI from archinstall.lib.profiles import Profile if hasUEFI() is False: - archinstall.log("ArchInstall currently only supports machines booted with UEFI.\nMBR & GRUB support is coming in version 2.2.0!", fg="red", level=archinstall.LOG_LEVELS.Error) + archinstall.log(" * ArchInstall currently only supports machines booted with UEFI.\nMBR & GRUB support is coming in version 2.2.0! * ", fg='red', level=archinstall.LOG_LEVELS.Error) exit(1) def ask_user_questions(): @@ -18,8 +18,8 @@ def ask_user_questions(): try: archinstall.arguments['keyboard-language'] = archinstall.select_language(archinstall.list_keyboard_languages()).strip() break - except archinstall.RequirementError as err: - archinstall.log(err, fg="red") + except archinstall.RequirementError as e: + archinstall.log(f" * {e} * ", fg='red') # Before continuing, set the preferred keyboard layout/language in the current terminal. # This will just help the user with the next following questions. @@ -33,7 +33,7 @@ def ask_user_questions(): archinstall.arguments['mirror-region'] = archinstall.select_mirror_regions(archinstall.list_mirrors()) break except archinstall.RequirementError as e: - archinstall.log(e, fg="red") + archinstall.log(f" * {e} * ", fg='red') else: selected_region = archinstall.arguments['mirror-region'] archinstall.arguments['mirror-region'] = {selected_region : archinstall.list_mirrors()[selected_region]} @@ -67,13 +67,13 @@ def ask_user_questions(): # We then ask what to do with the partitions. if (option := archinstall.ask_for_disk_layout()) == 'abort': - archinstall.log(f"Safely aborting the installation. No changes to the disk or system has been made.") + archinstall.log('Safely aborting the installation. No changes to the disk or system has been made', fg='yellow') exit(1) elif option == 'keep-existing': archinstall.arguments['harddrive'].keep_partitions = True - archinstall.log(f" ** You will now select which partitions to use by selecting mount points (inside the installation). **") - archinstall.log(f" ** The root would be a simple / and the boot partition /boot (as all paths are relative inside the installation). **") + archinstall.log(' -- You will now select which partitions to use by selecting mount points (inside the installation) -- ') + archinstall.log(' -- The root would be a simple / and the boot partition /boot (as all paths are relative inside the installation) -- ') mountpoints_set = [] while True: # Select a partition @@ -103,8 +103,8 @@ def ask_user_questions(): if (autodetected_filesystem := partition.detect_inner_filesystem(old_password)): new_filesystem = autodetected_filesystem else: - archinstall.log(f"Could not auto-detect the filesystem inside the encrypted volume.", fg='red') - archinstall.log(f"A filesystem must be defined for the unlocked encrypted partition.") + archinstall.log(' * Could not auto-detect the filesystem inside the encrypted volume * ', fg='red') + archinstall.log('A filesystem must be defined for the unlocked encrypted partition') continue break @@ -114,8 +114,9 @@ def ask_user_questions(): try: partition.format(new_filesystem, path='/dev/null', log_formatting=False, allow_formatting=True) except archinstall.UnknownFilesystemFormat: - archinstall.log(f"Selected filesystem is not supported yet. If you want archinstall to support '{new_filesystem}', please create a issue-ticket suggesting it on github at https://github.com/archlinux/archinstall/issues.") - archinstall.log(f"Until then, please enter another supported filesystem.") + archinstall.log(' * Selected filesystem is not supported yet * ', fg='red') + archinstall.log(f"If you want archinstall to support '{new_filesystem}', please create a issue-ticket suggesting it on github at https://github.com/archlinux/archinstall/issues.") + archinstall.log('Until then, please enter another supported filesystem') continue except archinstall.SysCallError: pass # Expected exception since mkfs. can not format /dev/null. @@ -178,7 +179,7 @@ def ask_user_questions(): with archinstall.arguments['profile'].load_instructions(namespace=f"{archinstall.arguments['profile'].namespace}.py") as imported: if not imported._prep_function(): archinstall.log( - ' * Profile\'s preparation requirements was not fulfilled.', + ' * Profile\'s preparation requirements was not fulfilled * ', fg='red' ) exit(1) @@ -204,11 +205,11 @@ def ask_user_questions(): if len(archinstall.arguments['packages']): # Verify packages that were given try: - archinstall.log(f"Verifying that additional packages exist (this might take a few seconds)") + archinstall.log('Verifying that additional packages exist (this might take a few seconds)', fg='yellow') archinstall.validate_package_list(archinstall.arguments['packages']) break except archinstall.RequirementError as e: - archinstall.log(e, fg='red') + archinstall.log(f" * {e} * ", fg='red') archinstall.arguments['packages'] = None # Clear the packages to trigger a new input question else: # no additional packages were selected, which we'll allow @@ -218,7 +219,7 @@ def ask_user_questions(): if not archinstall.arguments.get('nic', None): archinstall.arguments['nic'] = archinstall.ask_to_configure_network() if not archinstall.arguments['nic']: - archinstall.log(f"No network configuration was selected. Network is going to be unavailable until configured manually!", fg="yellow") + archinstall.log('No network configuration was selected. Network is going to be unavailable until configured manually!', fg='yellow') if not archinstall.arguments.get('timezone', None): archinstall.arguments['timezone'] = archinstall.ask_for_a_timezone() @@ -299,7 +300,7 @@ def perform_installation(mountpoint): # Certain services might be running that affects the system during installation. # Currently, only one such service is "reflector.service" which updates /etc/pacman.d/mirrorlist # We need to wait for it before we continue since we opted in to use a custom mirror/region. - installation.log(f'Waiting for automatic mirror selection (reflector) to complete.', level=archinstall.LOG_LEVELS.Info) + installation.log('Waiting for automatic mirror selection (reflector) to complete...', level=archinstall.LOG_LEVELS.Info) while archinstall.service_state('reflector') not in ('dead', 'failed'): time.sleep(1) @@ -356,9 +357,9 @@ def perform_installation(mountpoint): if (root_pw := archinstall.arguments.get('!root-password', None)) and len(root_pw): installation.user_set_pw('root', root_pw) - installation.log("For post-installation tips, see https://wiki.archlinux.org/index.php/Installation_guide#Post-installation", fg="yellow") - choice = input("Would you like to chroot into the newly created installation and perform post-installation configuration? [Y/n] ") - if choice.lower() in ("y", ""): + installation.log('For post-installation tips, see https://wiki.archlinux.org/index.php/Installation_guide#Post-installation', fg='yellow') + choice = input('Would you like to chroot into the newly created installation and perform post-installation configuration? [Y/n] ') + if choice.lower() in ('y', ''): try: installation.drop_to_shell() except: -- cgit v1.2.3-54-g00ecf From 985b7fac3ff400de9954d441480ab795222f4b24 Mon Sep 17 00:00:00 2001 From: SecondThundeR Date: Tue, 27 Apr 2021 15:14:28 +0300 Subject: Revert "Update logging for some functions" This reverts commit f5b6e7bafead1f604c27bfb31b84f3f560a682c8. Reverting commit due to currently redundant change and merge conflict --- archinstall/lib/disk.py | 4 ++-- archinstall/lib/installer.py | 10 +++++----- archinstall/lib/mirrors.py | 2 +- archinstall/lib/output.py | 4 ++-- archinstall/lib/user_interaction.py | 25 +++++++++++++++--------- examples/guided.py | 39 ++++++++++++++++++------------------- 6 files changed, 45 insertions(+), 39 deletions(-) diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index de93556a..bada4076 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -128,7 +128,7 @@ class BlockDevice(): @property def uuid(self): - log('BlockDevice().uuid is untested!', level=LOG_LEVELS.Warning, fg='yellow') + log(f'BlockDevice().uuid is untested!', level=LOG_LEVELS.Warning, fg='yellow') """ Returns the disk UUID as returned by lsblk. This is more reliable than relying on /dev/disk/by-partuuid as @@ -292,7 +292,7 @@ class Partition(): raise DiskError(f"Attempting to encrypt a partition that was not marked for encryption: {self}") if not self.safe_to_format(): - log(f" * Partition {self} was marked as protected but encrypt() was called on it! * ", level=LOG_LEVELS.Error, fg='red') + log(f"Partition {self} was marked as protected but encrypt() was called on it!", level=LOG_LEVELS.Error, fg="red") return False handle = luks2(self, None, None) diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index c64079f6..758033a7 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -79,14 +79,14 @@ class Installer(): self.genfstab() if not (missing_steps := self.post_install_check()): - self.log('Installation completed without any errors. You may now reboot.', fg='green', level=LOG_LEVELS.Info) + self.log('Installation completed without any errors. You may now reboot.', bg='black', fg='green', level=LOG_LEVELS.Info) self.sync_log_to_install_medium() return True else: - self.log('Some required steps were not successfully installed/configured before leaving the installer:', fg='red', level=LOG_LEVELS.Warning) + self.log('Some required steps were not successfully installed/configured before leaving the installer:', bg='black', fg='red', level=LOG_LEVELS.Warning) for step in missing_steps: - self.log(f' - {step}', fg='red', level=LOG_LEVELS.Warning) + self.log(f' - {step}', bg='black', fg='red', level=LOG_LEVELS.Warning) self.log(f"Detailed error logs can be found at: {storage['LOG_PATH']}", level=LOG_LEVELS.Warning) self.log(f"Submit this zip file as an issue to https://github.com/archlinux/archinstall/issues", level=LOG_LEVELS.Warning) @@ -168,7 +168,7 @@ class Installer(): return True else: self.log( - f" * Timezone \"{zone}\" does not exist, continuing with system default * ", + f"Time zone {zone} does not exist, continuing with system default.", level=LOG_LEVELS.Warning, fg='red' ) @@ -460,5 +460,5 @@ class Installer(): vconsole.write(f'KEYMAP={language}\n') vconsole.write(f'FONT=lat9w-16\n') else: - self.log('Keyboard language was not changed from default (no language specified).', fg='yellow', level=LOG_LEVELS.Info) + self.log(f'Keyboard language was not changed from default (no language specified).', fg="yellow", level=LOG_LEVELS.Info) return True diff --git a/archinstall/lib/mirrors.py b/archinstall/lib/mirrors.py index 57271bf8..04f47c0d 100644 --- a/archinstall/lib/mirrors.py +++ b/archinstall/lib/mirrors.py @@ -79,7 +79,7 @@ def list_mirrors(): try: response = urllib.request.urlopen(url) except urllib.error.URLError as err: - log(f"Could not fetch an active mirror-list: {err}", level=LOG_LEVELS.Warning, fg='yellow') + log(f'Could not fetch an active mirror-list: {err}', level=LOG_LEVELS.Warning, fg="yellow") return regions diff --git a/archinstall/lib/output.py b/archinstall/lib/output.py index eb23faf4..6b184b4b 100644 --- a/archinstall/lib/output.py +++ b/archinstall/lib/output.py @@ -100,12 +100,12 @@ def log(*args, **kwargs): Path(absolute_logfile).parents[0].mkdir(exist_ok=True, parents=True) except PermissionError: # Fallback to creating the log file in the current folder - err_string = f" * Not enough permission to place log file at {absolute_logfile}, creating it in {Path('./').absolute()/filename} instead * " + err_string = f"Not enough permission to place log file at {absolute_logfile}, creating it in {Path('./').absolute()/filename} instead." absolute_logfile = Path('./').absolute()/filename absolute_logfile.parents[0].mkdir(exist_ok=True) absolute_logfile = str(absolute_logfile) storage['LOG_PATH'] = './' - log(err_string, fg='red') + log(err_string, fg="red") Path(absolute_logfile).touch() # Overkill? diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index ec6b6d34..572acf4f 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -22,7 +22,11 @@ def get_longest_option(options): def check_for_correct_username(username): if re.match(r'^[a-z_][a-z0-9_-]*\$?$', username) and len(username) <= 32: return True - log(' * The username you entered is invalid. Try again * ', fg='red') + log( + "The username you entered is invalid. Try again", + level=LOG_LEVELS.Warning, + fg='red' + ) return False def do_countdown(): @@ -134,7 +138,8 @@ def ask_for_a_timezone(): return timezone else: log( - f"* Specified timezone {timezone} does not exist * ", + f"Specified timezone {timezone} does not exist.", + level=LOG_LEVELS.Warning, fg='red' ) @@ -180,7 +185,8 @@ def ask_to_configure_network(): break except ValueError: log( - 'You need to enter a valid IP in IP-config mode', + "You need to enter a valid IP in IP-config mode.", + level=LOG_LEVELS.Warning, fg='red' ) @@ -195,7 +201,8 @@ def ask_to_configure_network(): break except ValueError: log( - 'You need to enter a valid gateway (router) IP address', + "You need to enter a valid gateway (router) IP address.", + level=LOG_LEVELS.Warning, fg='red' ) @@ -251,15 +258,15 @@ def generic_select(options, input_text="Select one of the above by index or abso # Checking if options are different from `list` or `dict` if type(options) not in [list, dict]: log(f" * Generic select doesn't support ({type(options)}) as type of options * ", fg='red') - log('If problem persists, please create an issue on https://github.com/archlinux/archinstall/issues', fg='yellow') + log(" * If problem persists, please create an issue on https://github.com/archlinux/archinstall/issues * ", fg='yellow') raise RequirementError("generic_select() requires list or dictionary as options.") # To allow only `list` and `dict`, converting values of options here. # Therefore, now we can only provide the dictionary itself if type(options) == dict: options = list(options.values()) if sort: options = sorted(options) # As we pass only list and dict (converted to list), we can skip converting to list if len(options) == 0: - log(' * Generic select didn\'t find any options to choose from * ', fg='red') - log('If problem persists, please create an issue on https://github.com/archlinux/archinstall/issues', fg='yellow') + log(f" * Generic select didn't find any options to choose from * ", fg='red') + log(" * If problem persists, please create an issue on https://github.com/archlinux/archinstall/issues * ", fg='yellow') raise RequirementError('generic_select() requires at least one option to proceed.') @@ -391,7 +398,7 @@ def select_language(options, show_only_country_codes=True): new_options = list(search_keyboard_layout(filter_string)) if len(new_options) <= 0: - log(f"Search string '{filter_string}' yielded no results, please try another search", fg='yellow') + log(f"Search string '{filter_string}' yielded no results, please try another search.", fg='yellow') continue return select_language(new_options, show_only_country_codes=False) @@ -404,7 +411,7 @@ def select_language(options, show_only_country_codes=True): elif verify_keyboard_layout(selected_language): return selected_language else: - log(' * Given language was not found * ', fg='red') + log(" * Given language wasn't found * ", fg='red') raise RequirementError("Selecting languages require a least one language to be given as an option.") diff --git a/examples/guided.py b/examples/guided.py index f89efa45..cc9cf5fc 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -4,7 +4,7 @@ from archinstall.lib.hardware import hasUEFI from archinstall.lib.profiles import Profile if hasUEFI() is False: - archinstall.log(" * ArchInstall currently only supports machines booted with UEFI.\nMBR & GRUB support is coming in version 2.2.0! * ", fg='red', level=archinstall.LOG_LEVELS.Error) + archinstall.log("ArchInstall currently only supports machines booted with UEFI.\nMBR & GRUB support is coming in version 2.2.0!", fg="red", level=archinstall.LOG_LEVELS.Error) exit(1) def ask_user_questions(): @@ -18,8 +18,8 @@ def ask_user_questions(): try: archinstall.arguments['keyboard-language'] = archinstall.select_language(archinstall.list_keyboard_languages()).strip() break - except archinstall.RequirementError as e: - archinstall.log(f" * {e} * ", fg='red') + except archinstall.RequirementError as err: + archinstall.log(err, fg="red") # Before continuing, set the preferred keyboard layout/language in the current terminal. # This will just help the user with the next following questions. @@ -33,7 +33,7 @@ def ask_user_questions(): archinstall.arguments['mirror-region'] = archinstall.select_mirror_regions(archinstall.list_mirrors()) break except archinstall.RequirementError as e: - archinstall.log(f" * {e} * ", fg='red') + archinstall.log(e, fg="red") else: selected_region = archinstall.arguments['mirror-region'] archinstall.arguments['mirror-region'] = {selected_region : archinstall.list_mirrors()[selected_region]} @@ -67,13 +67,13 @@ def ask_user_questions(): # We then ask what to do with the partitions. if (option := archinstall.ask_for_disk_layout()) == 'abort': - archinstall.log('Safely aborting the installation. No changes to the disk or system has been made', fg='yellow') + archinstall.log(f"Safely aborting the installation. No changes to the disk or system has been made.") exit(1) elif option == 'keep-existing': archinstall.arguments['harddrive'].keep_partitions = True - archinstall.log(' -- You will now select which partitions to use by selecting mount points (inside the installation) -- ') - archinstall.log(' -- The root would be a simple / and the boot partition /boot (as all paths are relative inside the installation) -- ') + archinstall.log(f" ** You will now select which partitions to use by selecting mount points (inside the installation). **") + archinstall.log(f" ** The root would be a simple / and the boot partition /boot (as all paths are relative inside the installation). **") mountpoints_set = [] while True: # Select a partition @@ -103,8 +103,8 @@ def ask_user_questions(): if (autodetected_filesystem := partition.detect_inner_filesystem(old_password)): new_filesystem = autodetected_filesystem else: - archinstall.log(' * Could not auto-detect the filesystem inside the encrypted volume * ', fg='red') - archinstall.log('A filesystem must be defined for the unlocked encrypted partition') + archinstall.log(f"Could not auto-detect the filesystem inside the encrypted volume.", fg='red') + archinstall.log(f"A filesystem must be defined for the unlocked encrypted partition.") continue break @@ -114,9 +114,8 @@ def ask_user_questions(): try: partition.format(new_filesystem, path='/dev/null', log_formatting=False, allow_formatting=True) except archinstall.UnknownFilesystemFormat: - archinstall.log(' * Selected filesystem is not supported yet * ', fg='red') - archinstall.log(f"If you want archinstall to support '{new_filesystem}', please create a issue-ticket suggesting it on github at https://github.com/archlinux/archinstall/issues.") - archinstall.log('Until then, please enter another supported filesystem') + archinstall.log(f"Selected filesystem is not supported yet. If you want archinstall to support '{new_filesystem}', please create a issue-ticket suggesting it on github at https://github.com/archlinux/archinstall/issues.") + archinstall.log(f"Until then, please enter another supported filesystem.") continue except archinstall.SysCallError: pass # Expected exception since mkfs. can not format /dev/null. @@ -179,7 +178,7 @@ def ask_user_questions(): with archinstall.arguments['profile'].load_instructions(namespace=f"{archinstall.arguments['profile'].namespace}.py") as imported: if not imported._prep_function(): archinstall.log( - ' * Profile\'s preparation requirements was not fulfilled * ', + ' * Profile\'s preparation requirements was not fulfilled.', fg='red' ) exit(1) @@ -205,11 +204,11 @@ def ask_user_questions(): if len(archinstall.arguments['packages']): # Verify packages that were given try: - archinstall.log('Verifying that additional packages exist (this might take a few seconds)', fg='yellow') + archinstall.log(f"Verifying that additional packages exist (this might take a few seconds)") archinstall.validate_package_list(archinstall.arguments['packages']) break except archinstall.RequirementError as e: - archinstall.log(f" * {e} * ", fg='red') + archinstall.log(e, fg='red') archinstall.arguments['packages'] = None # Clear the packages to trigger a new input question else: # no additional packages were selected, which we'll allow @@ -219,7 +218,7 @@ def ask_user_questions(): if not archinstall.arguments.get('nic', None): archinstall.arguments['nic'] = archinstall.ask_to_configure_network() if not archinstall.arguments['nic']: - archinstall.log('No network configuration was selected. Network is going to be unavailable until configured manually!', fg='yellow') + archinstall.log(f"No network configuration was selected. Network is going to be unavailable until configured manually!", fg="yellow") if not archinstall.arguments.get('timezone', None): archinstall.arguments['timezone'] = archinstall.ask_for_a_timezone() @@ -300,7 +299,7 @@ def perform_installation(mountpoint): # Certain services might be running that affects the system during installation. # Currently, only one such service is "reflector.service" which updates /etc/pacman.d/mirrorlist # We need to wait for it before we continue since we opted in to use a custom mirror/region. - installation.log('Waiting for automatic mirror selection (reflector) to complete...', level=archinstall.LOG_LEVELS.Info) + installation.log(f'Waiting for automatic mirror selection (reflector) to complete.', level=archinstall.LOG_LEVELS.Info) while archinstall.service_state('reflector') not in ('dead', 'failed'): time.sleep(1) @@ -357,9 +356,9 @@ def perform_installation(mountpoint): if (root_pw := archinstall.arguments.get('!root-password', None)) and len(root_pw): installation.user_set_pw('root', root_pw) - installation.log('For post-installation tips, see https://wiki.archlinux.org/index.php/Installation_guide#Post-installation', fg='yellow') - choice = input('Would you like to chroot into the newly created installation and perform post-installation configuration? [Y/n] ') - if choice.lower() in ('y', ''): + installation.log("For post-installation tips, see https://wiki.archlinux.org/index.php/Installation_guide#Post-installation", fg="yellow") + choice = input("Would you like to chroot into the newly created installation and perform post-installation configuration? [Y/n] ") + if choice.lower() in ("y", ""): try: installation.drop_to_shell() except: -- cgit v1.2.3-54-g00ecf From 492c44c916312460b831e9c5d9308a48fffdeb7d Mon Sep 17 00:00:00 2001 From: Владислав Date: Tue, 27 Apr 2021 15:39:32 +0300 Subject: Restore changes related to background properties --- archinstall/lib/installer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index e2762603..95978e42 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -89,14 +89,14 @@ class Installer(): self.genfstab() if not (missing_steps := self.post_install_check()): - self.log('Installation completed without any errors. You may now reboot.', bg='black', fg='green', level=LOG_LEVELS.Info) + self.log('Installation completed without any errors. You may now reboot.', fg='green', level=LOG_LEVELS.Info) self.sync_log_to_install_medium() return True else: - self.log('Some required steps were not successfully installed/configured before leaving the installer:', bg='black', fg='red', level=LOG_LEVELS.Warning) + self.log('Some required steps were not successfully installed/configured before leaving the installer:', fg='red', level=LOG_LEVELS.Warning) for step in missing_steps: - self.log(f' - {step}', bg='black', fg='red', level=LOG_LEVELS.Warning) + self.log(f' - {step}', fg='red', level=LOG_LEVELS.Warning) self.log(f"Detailed error logs can be found at: {storage['LOG_PATH']}", level=LOG_LEVELS.Warning) self.log(f"Submit this zip file as an issue to https://github.com/archlinux/archinstall/issues", level=LOG_LEVELS.Warning) -- cgit v1.2.3-54-g00ecf From a706a98151fcd80d414c5184c3e9325aaab475ec Mon Sep 17 00:00:00 2001 From: SecondThundeR Date: Tue, 27 Apr 2021 19:19:33 +0300 Subject: Revert some merge resolve changes --- archinstall/lib/installer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 04fe44c8..577a2ae1 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -90,14 +90,14 @@ class Installer(): self.genfstab() if not (missing_steps := self.post_install_check()): - self.log('Installation completed without any errors. You may now reboot.', bg='black', fg='green', level=logging.INFO) + self.log('Installation completed without any errors. You may now reboot.', fg='green', level=logging.INFO) self.sync_log_to_install_medium() return True else: - self.log('Some required steps were not successfully installed/configured before leaving the installer:', bg='black', fg='red', level=logging.WARNING) + self.log('Some required steps were not successfully installed/configured before leaving the installer:', fg='red', level=logging.WARNING) for step in missing_steps: - self.log(f' - {step}', bg='black', fg='red', level=logging.WARNING) + self.log(f' - {step}', fg='red', level=logging.WARNING) self.log(f"Detailed error logs can be found at: {storage['LOG_PATH']}", level=logging.WARNING) self.log(f"Submit this zip file as an issue to https://github.com/archlinux/archinstall/issues", level=logging.WARNING) -- cgit v1.2.3-54-g00ecf