Skip to content

Commit 11a69e4

Browse files
committed
Change keyring priority
1 parent 1c27d37 commit 11a69e4

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

src/vorta/keyring/abc.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,27 @@ def get_keyring(cls):
2020
if sys.platform == 'darwin': # Use Keychain on macOS
2121
from .darwin import VortaDarwinKeyring
2222
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
2633

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
3239

33-
try:
34-
cls._keyring = VortaSecretStorageKeyring()
35-
except (secretstorage.exceptions.SecretStorageException, DBusException): # Try to use KWallet (KDE)
36-
from .kwallet import VortaKWallet5Keyring, KWalletNotAvailableException
3740
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.
4044
from .db import VortaDBKeyring
4145
cls._keyring = VortaDBKeyring()
4246
return cls._keyring

0 commit comments

Comments
 (0)