@@ -20,23 +20,27 @@ def get_keyring(cls):
20
20
if sys .platform == 'darwin' : # Use Keychain on macOS
21
21
from .darwin import VortaDarwinKeyring
22
22
cls ._keyring = VortaDarwinKeyring ()
23
- else : # Try to use DBus and Gnome-Keyring (available on Linux and *BSD)
24
- import secretstorage
25
- from .secretstorage import VortaSecretStorageKeyring
23
+ else :
24
+ # Try to use KWallet (KDE)
25
+ from .kwallet import VortaKWallet5Keyring , KWalletNotAvailableException
26
+ try :
27
+ cls ._keyring = VortaKWallet5Keyring ()
28
+ except KWalletNotAvailableException :
29
+ # Try to use DBus and Gnome-Keyring (available on Linux and *BSD)
30
+ # Put this last as secretstorage is included by default on many distros
31
+ import secretstorage
32
+ from .secretstorage import VortaSecretStorageKeyring
26
33
27
- # secretstorage has two different libraries based on version
28
- if parse_version (secretstorage .__version__ ) >= parse_version ("3.0.0" ):
29
- from jeepney .wrappers import DBusErrorResponse as DBusException
30
- else :
31
- from dbus .exceptions import DBusException
34
+ # secretstorage has two different libraries based on version
35
+ if parse_version (secretstorage .__version__ ) >= parse_version ("3.0.0" ):
36
+ from jeepney .wrappers import DBusErrorResponse as DBusException
37
+ else :
38
+ from dbus .exceptions import DBusException
32
39
33
- try :
34
- cls ._keyring = VortaSecretStorageKeyring ()
35
- except (secretstorage .exceptions .SecretStorageException , DBusException ): # Try to use KWallet (KDE)
36
- from .kwallet import VortaKWallet5Keyring , KWalletNotAvailableException
37
40
try :
38
- cls ._keyring = VortaKWallet5Keyring ()
39
- except KWalletNotAvailableException : # Save passwords in DB, if all else fails.
41
+ cls ._keyring = VortaSecretStorageKeyring ()
42
+ except (secretstorage .exceptions .SecretStorageException , DBusException ):
43
+ # Save passwords in DB, if all else fails.
40
44
from .db import VortaDBKeyring
41
45
cls ._keyring = VortaDBKeyring ()
42
46
return cls ._keyring
0 commit comments