From 36a8f850dca1fc84b28c5c43a94cdbfa49558dab Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Fri, 11 Mar 2022 15:23:40 +0100 Subject: [PATCH 1/4] Redirect users to support forum for a better experience --- pynitrokey/confconsts.py | 1 + pynitrokey/helpers.py | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pynitrokey/confconsts.py b/pynitrokey/confconsts.py index de36d985..f4133cb7 100644 --- a/pynitrokey/confconsts.py +++ b/pynitrokey/confconsts.py @@ -42,4 +42,5 @@ class Verbosity(IntEnum): LOG_FORMAT = "%(relativeCreated)-8d %(levelname)6s %(name)10s %(message)s" GH_ISSUES_URL = "https://github.com/Nitrokey/pynitrokey/issues/" +SUPPORT_URL = "https://support.nitrokey.com/" SUPPORT_EMAIL = "support@nitrokey.com" diff --git a/pynitrokey/helpers.py b/pynitrokey/helpers.py index 72f81b2a..a8a51206 100644 --- a/pynitrokey/helpers.py +++ b/pynitrokey/helpers.py @@ -22,6 +22,7 @@ GH_ISSUES_URL, LOG_FN, SUPPORT_EMAIL, + SUPPORT_URL, VERBOSE, Verbosity, ) @@ -206,9 +207,9 @@ def local_critical(*messages, support_hint=True, ret_code=1, **kwargs): "", "-" * 80, "Critical error occurred, exiting now", - "Unexpected? Is this a bug? Do you would like to get support/help?", - f"- You can report issues at: {GH_ISSUES_URL}", - f"- Writing an e-mail to: {SUPPORT_EMAIL} is also possible", + "Unexpected? Is this a bug? Would you like to get support/help?", + f"- You can report issues at: {SUPPORT_URL}", + f"- Writing an e-mail to {SUPPORT_EMAIL} is also possible", f"- Please attach the log: '{LOG_FN}' with any support/help request!", "-" * 80, "", From 6c9127c29ea0ff4a3326c0125967960650cc285d Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Fri, 11 Mar 2022 15:23:57 +0100 Subject: [PATCH 2/4] Handle uncaught exceptions in local_critical during devices listing --- pynitrokey/helpers.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pynitrokey/helpers.py b/pynitrokey/helpers.py index a8a51206..7594de62 100644 --- a/pynitrokey/helpers.py +++ b/pynitrokey/helpers.py @@ -198,9 +198,16 @@ def local_critical(*messages, support_hint=True, ret_code=1, **kwargs): # @fixme: not the best solution STDOUT_PRINT = False local_print("listing all connected devices:") - from pynitrokey.cli import nitropy - nitropy.commands["list"].callback() + try: + from pynitrokey.cli import nitropy + + nitropy.commands["list"].callback() + except Exception: + local_print("Unable to list devices. See log for the details.") + logger = logging.getLogger() + logger.exception("Unable to list devices") + STDOUT_PRINT = True local_print( From fbe136501c6a8ad10e8116794290daf2e9949c6b Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Thu, 10 Mar 2022 12:26:52 +0100 Subject: [PATCH 3/4] Correct typos --- pynitrokey/cli/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pynitrokey/cli/__init__.py b/pynitrokey/cli/__init__.py index c8a7332b..220cc537 100644 --- a/pynitrokey/cli/__init__.py +++ b/pynitrokey/cli/__init__.py @@ -110,5 +110,5 @@ def main() -> None: except CliException as e: e.show() except Exception as e: - logger.warning("An unhandled exception occured", exc_info=True) - local_critical("An unhandled exception occured", e) + logger.warning("An unhandled exception occurred", exc_info=True) + local_critical("An unhandled exception occurred", e) From e9d3d8278023bbe053562fefbc377cc053bd1b14 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Thu, 10 Mar 2022 12:27:08 +0100 Subject: [PATCH 4/4] Comments --- pynitrokey/cli/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pynitrokey/cli/__init__.py b/pynitrokey/cli/__init__.py index 220cc537..e95b1394 100644 --- a/pynitrokey/cli/__init__.py +++ b/pynitrokey/cli/__init__.py @@ -86,6 +86,7 @@ def _list(): fido2.commands["list"].callback() start.commands["list"].callback() nk3.commands["list"].callback() + # TODO add other handled models @click.command()