From 50067b57fb331f56d29074a60647453de3e4f789 Mon Sep 17 00:00:00 2001 From: kmohrf Date: Tue, 9 Apr 2024 02:19:43 +0200 Subject: [PATCH] fix: improve forwards compatibility with spsdk 2.1+ spsdk recently switched to the python-native Enum library and renamed the `desc` method to `get_description` in the process. By using device.status_string instead, our code works with both versions. Co-authored-by: Robin Krahl --- pynitrokey/trussed/bootloader/lpc55.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/pynitrokey/trussed/bootloader/lpc55.py b/pynitrokey/trussed/bootloader/lpc55.py index 6686fb28..f6aa493c 100644 --- a/pynitrokey/trussed/bootloader/lpc55.py +++ b/pynitrokey/trussed/bootloader/lpc55.py @@ -58,10 +58,8 @@ def path(self) -> str: return self._path @property - def status(self) -> Tuple[int, str]: - code = self.device.status_code - message = StatusCode.desc(code) - return (code, message) + def status(self) -> str: + return self.device.status_string def close(self) -> None: self.device.close() @@ -103,10 +101,7 @@ def update( if success: self.reboot() else: - (code, message) = self.status - raise Exception( - f"Firmware update failed with status code {code}: {message}" - ) + raise Exception(f"Firmware update failed with status {self.status}") @classmethod def list_vid_pid(cls: type[T], vid: int, pid: int) -> list[T]: