do not do gnomekeyring.is_available check eveyrytime (only once); remove an assert
This commit is contained in:
parent
78e56c56e8
commit
d98263c5e8
|
@ -21,9 +21,12 @@ from common import gajim
|
||||||
try:
|
try:
|
||||||
import gnomekeyring
|
import gnomekeyring
|
||||||
except ImportError:
|
except ImportError:
|
||||||
USER_HAS_GNOMEKEYRING = False
|
USER_USES_GNOMEKEYRING = False
|
||||||
else:
|
else:
|
||||||
USER_HAS_GNOMEKEYRING = True
|
if gnomekeyring.is_available():
|
||||||
|
USER_USES_GNOMEKEYRING = True
|
||||||
|
else:
|
||||||
|
USER_USES_GNOMEKEYRING = False
|
||||||
|
|
||||||
class PasswordStorage(object):
|
class PasswordStorage(object):
|
||||||
def get_password(self, account_name):
|
def get_password(self, account_name):
|
||||||
|
@ -85,7 +88,7 @@ storage = None
|
||||||
def get_storage():
|
def get_storage():
|
||||||
global storage
|
global storage
|
||||||
if storage is None: # None is only in first time get_storage is called
|
if storage is None: # None is only in first time get_storage is called
|
||||||
if USER_HAS_GNOMEKEYRING and gnomekeyring.is_available():
|
if USER_USES_GNOMEKEYRING:
|
||||||
try:
|
try:
|
||||||
storage = GnomePasswordStorage()
|
storage = GnomePasswordStorage()
|
||||||
except gnomekeyring.NoKeyringDaemonError:
|
except gnomekeyring.NoKeyringDaemonError:
|
||||||
|
@ -96,7 +99,6 @@ def get_storage():
|
||||||
|
|
||||||
def set_storage(storage_):
|
def set_storage(storage_):
|
||||||
global storage
|
global storage
|
||||||
assert isinstance(storage, PasswordStorage)
|
|
||||||
storage = storage_
|
storage = storage_
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue