mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-11-02 20:52:20 -07:00
Handle storing None values in keyring
Write an empty string as value to the keyring if None is parsed and return a None value if an empty string was parsed from the keyring. CURA-7180_keyring_none_value
This commit is contained in:
parent
279edf7a37
commit
23ba1745a4
1 changed files with 3 additions and 2 deletions
|
|
@ -29,7 +29,8 @@ class KeyringAttribute:
|
||||||
def __get__(self, instance: Type["BaseModel"], owner: type) -> str:
|
def __get__(self, instance: Type["BaseModel"], owner: type) -> str:
|
||||||
if self._store_secure:
|
if self._store_secure:
|
||||||
try:
|
try:
|
||||||
return keyring.get_password("cura", self._keyring_name)
|
value = keyring.get_password("cura", self._keyring_name)
|
||||||
|
return value if value != "" else None
|
||||||
except NoKeyringError:
|
except NoKeyringError:
|
||||||
self._store_secure = False
|
self._store_secure = False
|
||||||
Logger.logException("w", "No keyring backend present")
|
Logger.logException("w", "No keyring backend present")
|
||||||
|
|
@ -41,7 +42,7 @@ class KeyringAttribute:
|
||||||
if self._store_secure:
|
if self._store_secure:
|
||||||
setattr(instance, self._name, None)
|
setattr(instance, self._name, None)
|
||||||
try:
|
try:
|
||||||
keyring.set_password("cura", self._keyring_name, value)
|
keyring.set_password("cura", self._keyring_name, value if value is not None else "")
|
||||||
except PasswordSetError:
|
except PasswordSetError:
|
||||||
self._store_secure = False
|
self._store_secure = False
|
||||||
if self._name not in DONT_EVER_STORE_LOCALLY:
|
if self._name not in DONT_EVER_STORE_LOCALLY:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue