From 1fd5b529f7240b686e4746275f7204340fa30794 Mon Sep 17 00:00:00 2001 From: Markus Meissner Date: Tue, 18 Jun 2024 12:10:55 +0200 Subject: [PATCH] nk3/update: add pre_bootloader_hint for update process --- pynitrokey/cli/nk3/update.py | 3 +++ pynitrokey/nk3/updates.py | 13 ++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/pynitrokey/cli/nk3/update.py b/pynitrokey/cli/nk3/update.py index 2cd2ec46..de47891c 100644 --- a/pynitrokey/cli/nk3/update.py +++ b/pynitrokey/cli/nk3/update.py @@ -95,6 +95,9 @@ def request_repeated_update(self) -> Exception: ) return Abort() + def pre_bootloader_hint(self) -> None: + pass + def request_bootloader_confirmation(self) -> None: local_print("") local_print( diff --git a/pynitrokey/nk3/updates.py b/pynitrokey/nk3/updates.py index 4899079e..36120a05 100644 --- a/pynitrokey/nk3/updates.py +++ b/pynitrokey/nk3/updates.py @@ -126,7 +126,11 @@ def confirm_update_same_version(self, version: Version) -> None: pass @abstractmethod - def request_repeated_update(self) -> Exception: + def request_repeated_update(self) -> Optional[Exception]: + pass + + @abstractmethod + def pre_bootloader_hint(self) -> None: pass @abstractmethod @@ -329,11 +333,14 @@ def _get_bootloader( # needed for udev to properly handle new device time.sleep(1) - if platform.system() == "Darwin": + maybe_exc = self.ui.request_repeated_update() + if platform.system() == "Darwin" and maybe_exc is not None: # Currently there is an issue with device enumeration after reboot on macOS, see # . To avoid this issue, we # cancel the command now and ask the user to run it again. - raise self.ui.request_repeated_update() + raise maybe_exc + + self.ui.pre_bootloader_hint() exc = None for t in Retries(3):