mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-20 04:58:32 +02:00
Better keyring error handling
This commit is contained in:
parent
4b973fe95d
commit
3b9d4f0b0c
1 changed files with 11 additions and 8 deletions
|
@ -176,7 +176,9 @@ def get_keychain(journal_name):
|
|||
|
||||
try:
|
||||
return keyring.get_password("jrnl", journal_name)
|
||||
except (keyring.errors.KeyringError, RuntimeError):
|
||||
except keyring.errors.KeyringError as e:
|
||||
if not isinstance(e, keyring.errors.NoKeyringError):
|
||||
print("Failed to retrieve keyring", file=sys.stderr)
|
||||
return ""
|
||||
|
||||
|
||||
|
@ -191,10 +193,11 @@ def set_keychain(journal_name, password):
|
|||
else:
|
||||
try:
|
||||
keyring.set_password("jrnl", journal_name, password)
|
||||
except (keyring.errors.KeyringError):
|
||||
pass
|
||||
except (keyring.errors.NoKeyringError):
|
||||
except keyring.errors.KeyringError as e:
|
||||
if isinstance(e, keyring.errors.NoKeyringError):
|
||||
print(
|
||||
"Keyring backend not found. Please install one of the supported backends by visiting: https://pypi.org/project/keyring/",
|
||||
file=sys.stderr,
|
||||
)
|
||||
else:
|
||||
print("Failed to retrieve keyring", file=sys.stderr)
|
||||
|
|
Loading…
Add table
Reference in a new issue