diff --git a/pynitrokey/cli/__init__.py b/pynitrokey/cli/__init__.py index 00b81e52..5308ff01 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() @@ -110,5 +111,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) 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..7594de62 100644 --- a/pynitrokey/helpers.py +++ b/pynitrokey/helpers.py @@ -22,6 +22,7 @@ GH_ISSUES_URL, LOG_FN, SUPPORT_EMAIL, + SUPPORT_URL, VERBOSE, Verbosity, ) @@ -197,18 +198,25 @@ 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( "", "-" * 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, "",