diff --git a/onlykey/cli.py b/onlykey/cli.py index 755941b..228a7a1 100644 --- a/onlykey/cli.py +++ b/onlykey/cli.py @@ -27,7 +27,13 @@ from .client import OnlyKey, Message, MessageField -only_key = OnlyKey() +# set 0 to disable Traceback output on exceptions +sys.tracebacklimit = 1 + +try: + only_key = OnlyKey() +except: + raise SystemExit def cli(): diff --git a/onlykey/client.py b/onlykey/client.py index 3e3c241..234dc6d 100644 --- a/onlykey/client.py +++ b/onlykey/client.py @@ -269,11 +269,15 @@ def _connect(self): self._hid = hid.device() self._hid.open_path(self.path) self._hid.set_nonblocking(True) + return else: + # FIDO Alliance Page if usage_page == 0xf1d0 or interface_number == 1: self._hid = hid.device() self._hid.open_path(self.path) self._hid.set_nonblocking(True) + return + raise OnlyKeyUnavailableException('device not found') except: log.exception('failed to connect')