From c1618565eafde6c91519961abee6ccd003bf70ea Mon Sep 17 00:00:00 2001 From: Konstantinos Karmas Date: Mon, 21 Jun 2021 10:47:53 +0200 Subject: [PATCH] Don't crash if keyring access is denied on MacOS CURA-8332 --- cura/OAuth2/KeyringAttribute.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cura/OAuth2/KeyringAttribute.py b/cura/OAuth2/KeyringAttribute.py index 12cdb94dd5..1fcd8a7f66 100644 --- a/cura/OAuth2/KeyringAttribute.py +++ b/cura/OAuth2/KeyringAttribute.py @@ -4,6 +4,7 @@ from typing import Type, TYPE_CHECKING, Optional, List import keyring from keyring.backend import KeyringBackend +from keyring.backends.macOS.api import KeychainDenied from keyring.errors import NoKeyringError, PasswordSetError from UM.Logger import Logger @@ -39,6 +40,14 @@ class KeyringAttribute: self._store_secure = False Logger.logException("w", "No keyring backend present") return getattr(instance, self._name) + except KeychainDenied: + self._store_secure = False + Logger.logException("w", "Access to the keyring was denied.") + return getattr(instance, self._name) + except Exception as e: + self._store_secure = False + Logger.logException("w", f"Something went wrong while trying to retrieve the password from the Keyring. Exception: {e}") + return getattr(instance, self._name) else: return getattr(instance, self._name)