diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 985e16cde8..6f928e5e6d 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -1480,20 +1480,20 @@ def _add_limine_bootloader( parent_dev_path = get_parent_device_path(efi_partition.safe_dev_path) - try: - efi_dir_path = self.target / efi_partition.mountpoint.relative_to('/') / 'EFI' - efi_dir_path_target = efi_partition.mountpoint / 'EFI' - if bootloader_removable: - efi_dir_path = efi_dir_path / 'BOOT' - efi_dir_path_target = efi_dir_path_target / 'BOOT' - else: - efi_dir_path = efi_dir_path / 'arch-limine' - efi_dir_path_target = efi_dir_path_target / 'arch-limine' + efi_dir_path = self.target / efi_partition.mountpoint.relative_to('/') / 'EFI' + efi_dir_path_target = efi_partition.mountpoint / 'EFI' + if bootloader_removable: + efi_dir_path = efi_dir_path / 'BOOT' + efi_dir_path_target = efi_dir_path_target / 'BOOT' + else: + efi_dir_path = efi_dir_path / 'arch-limine' + efi_dir_path_target = efi_dir_path_target / 'arch-limine' - config_path = efi_dir_path / 'limine.conf' + config_path = efi_dir_path / 'limine.conf' - efi_dir_path.mkdir(parents=True, exist_ok=True) + efi_dir_path.mkdir(parents=True, exist_ok=True) + try: for file in ('BOOTIA32.EFI', 'BOOTX64.EFI'): (limine_path / file).copy_into(efi_dir_path) except Exception as err: diff --git a/archinstall/lib/network/wifi_handler.py b/archinstall/lib/network/wifi_handler.py index bc068d2ae5..a0a3f05a88 100644 --- a/archinstall/lib/network/wifi_handler.py +++ b/archinstall/lib/network/wifi_handler.py @@ -58,7 +58,7 @@ async def run(self) -> bool | None: async def _enable_supplicant(self, wifi_iface: str) -> bool: self._wpa_config.load_config() - result = self._wpa_cli('status') # if it it's running it will blow up + result = self._wpa_cli('status') if result.success: debug('wpa_supplicant already running') @@ -72,18 +72,19 @@ async def _enable_supplicant(self, wifi_iface: str) -> bool: try: SysCommand(f'wpa_supplicant -B -i {wifi_iface} -c {self._wpa_config.config_file}') - result = self._wpa_cli('status') # if it it's running it will blow up - - if result.success: - debug('successfully enabled wpa_supplicant') - return True - else: - debug(f'failed to enable wpa_supplicant: {result.error}') - return False except SysCallError as err: debug(f'failed to enable wpa_supplicant: {err}') return False + result = self._wpa_cli('status') + + if result.success: + debug('successfully enabled wpa_supplicant') + return True + else: + debug(f'failed to enable wpa_supplicant: {result.error}') + return False + def _find_wifi_interface(self) -> str | None: net_path = Path('/sys/class/net') @@ -197,15 +198,6 @@ def _wpa_cli(self, command: str, iface: str | None = None) -> WpaCliResult: try: result = SysCommand(cmd).decode() - - if 'FAIL' in result: - debug(f'wpa_cli returned FAIL: {result}') - return WpaCliResult( - success=False, - error=f'wpa_cli returned a failure: {result}', - ) - - return WpaCliResult(success=True, response=result) except SysCallError as err: debug(f'error running wpa_cli command: {err}') return WpaCliResult( @@ -213,6 +205,15 @@ def _wpa_cli(self, command: str, iface: str | None = None) -> WpaCliResult: error=f'Error running wpa_cli command: {err}', ) + if 'FAIL' in result: + debug(f'wpa_cli returned FAIL: {result}') + return WpaCliResult( + success=False, + error=f'wpa_cli returned a failure: {result}', + ) + + return WpaCliResult(success=True, response=result) + def _find_network_id(self, ssid: str, iface: str) -> int | None: result = self._wpa_cli('list_networks', iface) @@ -254,18 +255,18 @@ def _get_scan_results(self, iface: str) -> list[WifiNetwork]: try: result = self._wpa_cli('scan_results', iface) + except SysCallError as err: + debug('Unable to retrieve wifi results') + raise err - if not result.success: - debug(f'Failed to retrieve scan results: {result.error}') - return [] + if not result.success: + debug(f'Failed to retrieve scan results: {result.error}') + return [] - if not result.response: - debug('No wifi networks found') - return [] + if not result.response: + debug('No wifi networks found') + return [] - networks = WifiNetwork.from_wpa(result.response) + networks = WifiNetwork.from_wpa(result.response) - return networks - except SysCallError as err: - debug('Unable to retrieve wifi results') - raise err + return networks diff --git a/archinstall/lib/profile/profiles_handler.py b/archinstall/lib/profile/profiles_handler.py index 1e770de52e..8430e0012c 100644 --- a/archinstall/lib/profile/profiles_handler.py +++ b/archinstall/lib/profile/profiles_handler.py @@ -258,6 +258,10 @@ def _import_profile_from_url(self, url: str) -> None: """ try: data = fetch_data_from_url(url) + except ValueError: + err = tr('Unable to fetch profile from specified url: {}').format(url) + error(err) + else: b_data = bytes(data, 'utf-8') with NamedTemporaryFile(delete=False, suffix='.py') as fp: @@ -266,10 +270,6 @@ def _import_profile_from_url(self, url: str) -> None: profiles = self._process_profile_file(filepath) self.remove_custom_profiles(profiles) - self.add_custom_profiles(profiles) - except ValueError: - err = tr('Unable to fetch profile from specified url: {}').format(url) - error(err) def _load_profile_class(self, module: ModuleType) -> list[Profile]: """ diff --git a/archinstall/lib/translationhandler.py b/archinstall/lib/translationhandler.py index c2736f3551..7da523b2fd 100644 --- a/archinstall/lib/translationhandler.py +++ b/archinstall/lib/translationhandler.py @@ -82,13 +82,14 @@ def save_console_font(self) -> None: if not running_from_iso(): return + font_fd, font_path = tempfile.mkstemp(prefix='archinstall_font_') + cmap_fd, cmap_path = tempfile.mkstemp(prefix='archinstall_cmap_') + os.close(font_fd) + os.close(cmap_fd) + self._font_backup = Path(font_path) + self._cmap_backup = Path(cmap_path) + try: - font_fd, font_path = tempfile.mkstemp(prefix='archinstall_font_') - cmap_fd, cmap_path = tempfile.mkstemp(prefix='archinstall_cmap_') - os.close(font_fd) - os.close(cmap_fd) - self._font_backup = Path(font_path) - self._cmap_backup = Path(cmap_path) SysCommand(['setfont', '-O', str(self._font_backup), '-om', str(self._cmap_backup)]) except SysCallError as err: debug(f'Failed to save console font: {err}') @@ -136,21 +137,21 @@ def _get_translations(self) -> list[Language]: try: # get a translation for a specific language translation = gettext.translation('base', localedir=self._get_locales_dir(), languages=(abbr, lang)) - - # calculate the percentage of total translated text to total number of messages - if abbr == 'en': - percent = 100 - else: - num_translations = self._get_catalog_size(translation) - percent = int((num_translations / self._total_messages) * 100) - # prevent cases where the .pot file is out of date and the percentage is above 100 - percent = min(100, percent) - - language = Language(abbr, lang, translation, percent, translated_lang, console_font) - languages.append(language) except FileNotFoundError as err: raise FileNotFoundError(f"Could not locate language file for '{lang}': {err}") + # calculate the percentage of total translated text to total number of messages + if abbr == 'en': + percent = 100 + else: + num_translations = self._get_catalog_size(translation) + percent = int((num_translations / self._total_messages) * 100) + # prevent cases where the .pot file is out of date and the percentage is above 100 + percent = min(100, percent) + + language = Language(abbr, lang, translation, percent, translated_lang, console_font) + languages.append(language) + return languages def _load_language_mappings(self) -> list[dict[str, str]]: