From 50355d241e5b51fb99aea0cd997aac6782501750 Mon Sep 17 00:00:00 2001 From: Dain Nilsson Date: Fri, 13 May 2022 09:03:13 +0200 Subject: [PATCH 1/3] Don't use dict union operator (requires Python 3.9). --- helper/helper/device.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/helper/helper/device.py b/helper/helper/device.py index d98cb8ef..62ffe32f 100644 --- a/helper/helper/device.py +++ b/helper/helper/device.py @@ -285,8 +285,9 @@ class UsbDeviceNode(AbstractDeviceNode): class ReaderDeviceNode(AbstractDeviceNode): def get_data(self): try: - return super().get_data() | dict(present=True) + return {**super().get_data(), "present": True} except Exception: + logger.debug("Couldn't get NFC device info, present=False", exc_info=True) return dict(present=False) @child From 661a8012cd595f89d48aafe2fbdb3b854433de84 Mon Sep 17 00:00:00 2001 From: Dain Nilsson Date: Fri, 13 May 2022 09:04:22 +0200 Subject: [PATCH 2/3] Clean up logging of exceptions. --- helper/helper/base.py | 4 ++-- helper/helper/device.py | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/helper/helper/base.py b/helper/helper/base.py index 89595caf..2883847e 100644 --- a/helper/helper/base.py +++ b/helper/helper/base.py @@ -195,8 +195,8 @@ class RpcNode: logger.debug("close existing child: %s", self._child_name) try: self._child.close() - except Exception as e: - logger.error("Error closing child", exc_info=e) + except Exception: + logger.exception("Error closing child") self._child = None self._child_name = None diff --git a/helper/helper/device.py b/helper/helper/device.py index 62ffe32f..179c57d2 100644 --- a/helper/helper/device.py +++ b/helper/helper/device.py @@ -225,8 +225,8 @@ class AbstractDeviceNode(RpcNode): def __call__(self, *args, **kwargs): try: return super().__call__(*args, **kwargs) - except (SmartcardException, OSError) as e: - logger.error("Device error", exc_info=e) + except (SmartcardException, OSError): + logger.exception("Device error") self._child = None name = self._child_name self._child_name = None @@ -236,7 +236,7 @@ class AbstractDeviceNode(RpcNode): try: return super().create_child(name) except (SmartcardException, OSError): - logger.error(f"Unable to create child {name}", exc_info=True) + logger.exception(f"Unable to create child {name}") raise NoSuchNodeException(name) def get_data(self): @@ -316,7 +316,7 @@ class ConnectionNode(RpcNode): try: return super().__call__(*args, **kwargs) except (SmartcardException, OSError) as e: - logger.error("Connection error", exc_info=e) + logger.exception("Connection error") raise ChildResetException(f"{e}") except ApduError as e: if e.sw == SW.INVALID_INSTRUCTION: @@ -331,8 +331,8 @@ class ConnectionNode(RpcNode): super().close() try: self._connection.close() - except Exception as e: - logger.warning("Error closing connection", exc_info=e) + except Exception: + logger.warning("Error closing connection", exc_info=True) def get_data(self): if ( From c3b895133e3d1f6083e951e7baea04bc5607251a Mon Sep 17 00:00:00 2001 From: Dain Nilsson Date: Fri, 13 May 2022 09:05:07 +0200 Subject: [PATCH 3/3] Bump Python dependencies. --- helper/poetry.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/helper/poetry.lock b/helper/poetry.lock index 30c9e18c..d5e63fb5 100755 --- a/helper/poetry.lock +++ b/helper/poetry.lock @@ -271,7 +271,7 @@ python-versions = ">=3.7" [[package]] name = "pyparsing" -version = "3.0.8" +version = "3.0.9" description = "pyparsing module - Classes and methods to define and execute parsing grammars" category = "dev" optional = false @@ -370,7 +370,7 @@ pywin32 = {version = ">=223", markers = "sys_platform == \"win32\""} type = "git" url = "https://github.com/Yubico/yubikey-manager.git" reference = "next" -resolved_reference = "61b902b5f61024b27f32ef88b2f95bb7630afdfb" +resolved_reference = "b1d05ea89f8988bf717e5e9073a4c3a3e7ec1bc2" [[package]] name = "zipp" @@ -626,8 +626,8 @@ pyinstaller-hooks-contrib = [ {file = "pyinstaller_hooks_contrib-2022.4-py2.py3-none-any.whl", hash = "sha256:b57a90bb8520d6e1dbbaaae416875e28fa5a3b74d2e40e330d02d1ccadacc38c"}, ] pyparsing = [ - {file = "pyparsing-3.0.8-py3-none-any.whl", hash = "sha256:ef7b523f6356f763771559412c0d7134753f037822dad1b16945b7b846f7ad06"}, - {file = "pyparsing-3.0.8.tar.gz", hash = "sha256:7bf433498c016c4314268d95df76c81b842a4cb2b276fa3312cfb1e1d85f6954"}, + {file = "pyparsing-3.0.9-py3-none-any.whl", hash = "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc"}, + {file = "pyparsing-3.0.9.tar.gz", hash = "sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb"}, ] pyscard = [ {file = "pyscard-2.0.3-cp310-cp310-win_amd64.whl", hash = "sha256:f7748157d293f57688307f94d780c93bd3ceaf309b39b92a0af792bf1ddb82e7"},