mirror of https://github.com/borgbase/vorta
Change keyring priority (#779)
This commit is contained in:
parent
1c27d377cf
commit
c99ac04b36
|
@ -20,23 +20,27 @@ class VortaKeyring:
|
|||
if sys.platform == 'darwin': # Use Keychain on macOS
|
||||
from .darwin import VortaDarwinKeyring
|
||||
cls._keyring = VortaDarwinKeyring()
|
||||
else: # Try to use DBus and Gnome-Keyring (available on Linux and *BSD)
|
||||
import secretstorage
|
||||
from .secretstorage import VortaSecretStorageKeyring
|
||||
|
||||
# secretstorage has two different libraries based on version
|
||||
if parse_version(secretstorage.__version__) >= parse_version("3.0.0"):
|
||||
from jeepney.wrappers import DBusErrorResponse as DBusException
|
||||
else:
|
||||
from dbus.exceptions import DBusException
|
||||
|
||||
else:
|
||||
# Try to use KWallet (KDE)
|
||||
from .kwallet import VortaKWallet5Keyring, KWalletNotAvailableException
|
||||
try:
|
||||
cls._keyring = VortaSecretStorageKeyring()
|
||||
except (secretstorage.exceptions.SecretStorageException, DBusException): # Try to use KWallet (KDE)
|
||||
from .kwallet import VortaKWallet5Keyring, KWalletNotAvailableException
|
||||
cls._keyring = VortaKWallet5Keyring()
|
||||
except KWalletNotAvailableException:
|
||||
# Try to use DBus and Gnome-Keyring (available on Linux and *BSD)
|
||||
# Put this last as gnome keyring is included by default on many distros
|
||||
import secretstorage
|
||||
from .secretstorage import VortaSecretStorageKeyring
|
||||
|
||||
# secretstorage has two different libraries based on version
|
||||
if parse_version(secretstorage.__version__) >= parse_version("3.0.0"):
|
||||
from jeepney.wrappers import DBusErrorResponse as DBusException
|
||||
else:
|
||||
from dbus.exceptions import DBusException
|
||||
|
||||
try:
|
||||
cls._keyring = VortaKWallet5Keyring()
|
||||
except KWalletNotAvailableException: # Save passwords in DB, if all else fails.
|
||||
cls._keyring = VortaSecretStorageKeyring()
|
||||
except (secretstorage.exceptions.SecretStorageException, DBusException):
|
||||
# Save passwords in DB, if all else fails.
|
||||
from .db import VortaDBKeyring
|
||||
cls._keyring = VortaDBKeyring()
|
||||
return cls._keyring
|
||||
|
|
Loading…
Reference in New Issue