Skip to content

Commit

Permalink
Merge pull request #236 from Nitrokey/pynk-upd
Browse files Browse the repository at this point in the history
bump pynitrokey to version 0.4.47
  • Loading branch information
jj-so authored Apr 19, 2024
2 parents 1eacc59 + 9d018ca commit a459f1a
Show file tree
Hide file tree
Showing 7 changed files with 356 additions and 280 deletions.
23 changes: 13 additions & 10 deletions nitrokeyapp/device_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
from typing import List, Optional

from pynitrokey import nk3
from pynitrokey.nk3 import Nitrokey3Base, Nitrokey3Device
from pynitrokey.nk3.admin_app import Status
from pynitrokey.nk3.utils import Uuid, Version
from pynitrokey.nk3.device import Nitrokey3Device
from pynitrokey.trussed.admin_app import Status
from pynitrokey.trussed.base import NitrokeyTrussedBase
from pynitrokey.trussed.device import NitrokeyTrussedDevice
from pynitrokey.trussed.utils import Uuid, Version

from nitrokeyapp.update import Nk3Context, UpdateGUI

logger = logging.getLogger(__name__)


class DeviceData:
def __init__(self, device: Nitrokey3Base) -> None:
def __init__(self, device: NitrokeyTrussedBase) -> None:
self.path = device.path
self.updating = False

Expand All @@ -34,25 +36,26 @@ def name(self) -> str:

@property
def is_bootloader(self) -> bool:
return not isinstance(self._device, Nitrokey3Device)
return not isinstance(self._device, NitrokeyTrussedDevice)

@property
def status(self) -> Status:
assert isinstance(self._device, Nitrokey3Device)
assert isinstance(self._device, NitrokeyTrussedDevice)
if not self._status:
self._status = self._device.admin.status()
return self._status

@property
def version(self) -> Version:
assert isinstance(self._device, Nitrokey3Device)
assert isinstance(self._device, NitrokeyTrussedDevice)
if not self._version:
self._version = self._device.version()
self._version = self._device.admin.version()

return self._version

@property
def uuid(self) -> Optional[Uuid]:
assert isinstance(self._device, Nitrokey3Device)
assert isinstance(self._device, NitrokeyTrussedDevice)
if not self._uuid:
self._uuid = self._device.uuid()
return self._uuid
Expand All @@ -63,7 +66,7 @@ def uuid_prefix(self) -> str:
The prefix of the UUID that is constant even when switching between
stable and test firmware.
"""
assert isinstance(self._device, Nitrokey3Device)
assert isinstance(self._device, NitrokeyTrussedDevice)
return str(self.uuid)[:5]

def open(self) -> Nitrokey3Device:
Expand Down
2 changes: 1 addition & 1 deletion nitrokeyapp/overview_tab/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
from typing import Optional

from pynitrokey.nk3.admin_app import InitStatus
from pynitrokey.trussed.admin_app import InitStatus
from PySide6.QtCore import QThread, Signal, Slot
from PySide6.QtWidgets import QFileDialog, QWidget

Expand Down
2 changes: 1 addition & 1 deletion nitrokeyapp/secrets_tab/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Dict, Optional

from pynitrokey.nk3.secrets_app import SecretsApp, SecretsAppException
from pynitrokey.nk3.utils import Uuid
from pynitrokey.trussed.utils import Uuid
from PySide6.QtCore import QObject, Signal, Slot
from PySide6.QtWidgets import QWidget

Expand Down
11 changes: 6 additions & 5 deletions nitrokeyapp/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,20 @@
from pynitrokey.helpers import Retries
from pynitrokey.nk3 import list as list_nk3
from pynitrokey.nk3 import open as open_nk3
from pynitrokey.nk3.base import Nitrokey3Base
from pynitrokey.nk3.bootloader import Nitrokey3Bootloader, Variant
from pynitrokey.nk3.bootloader import Nitrokey3Bootloader
from pynitrokey.nk3.device import Nitrokey3Device
from pynitrokey.nk3.updates import Updater, UpdateUi
from pynitrokey.nk3.utils import Version
from pynitrokey.trussed.base import NitrokeyTrussedBase
from pynitrokey.trussed.bootloader import Variant
from pynitrokey.trussed.utils import Version
from PySide6.QtCore import QCoreApplication

if TYPE_CHECKING:
from nitrokeyapp.common_ui import CommonUi

logger = logging.getLogger(__name__)

T = TypeVar("T", bound=Nitrokey3Base)
T = TypeVar("T", bound=NitrokeyTrussedBase)


class UpdateGUI(UpdateUi):
Expand Down Expand Up @@ -156,7 +157,7 @@ def __init__(self, path: str) -> None:
logger.info(f"path: {path}")
self.updating = False

def connect(self) -> Nitrokey3Base:
def connect(self) -> NitrokeyTrussedBase:
device = open_nk3(self.path)
# TODO: improve error handling
if not device:
Expand Down
2 changes: 1 addition & 1 deletion nitrokeyapp/welcome_tab.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import webbrowser
from typing import Optional

from pynitrokey.nk3.utils import Version
from pynitrokey.trussed.utils import Version
from pynitrokey.updates import Release, Repository
from PySide6.QtCore import Slot
from PySide6.QtWidgets import QWidget
Expand Down
Loading

0 comments on commit a459f1a

Please sign in to comment.