Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def iter_credentials():
try:
yield keyring.get_keyring().credentials
except AttributeError:
pass
try:
from oauth2client.client import (ApplicationDefaultCredentialsError,
GoogleCredentials)
yield GoogleCredentials.get_application_default()
except (ApplicationDefaultCredentialsError, ImportError):
pass
def load_token(self):
"""
Check if auth key has been saved.
:raises: ``KeyringLocked`` if the system keyring cannot be accessed.
"""
logger.debug("Using keyring: %s" % keyring.get_keyring())
try:
if self.account_id == "":
self.access_token = None
else:
self.access_token = keyring.get_password("Maestral", self.account_id)
return self.access_token
except KeyringLocked:
info = "Please make sure that your keyring is unlocked and restart Maestral."
raise KeyringLocked(info)
def _initialize_keyring():
try:
import keyring
except ImportError:
return
def _only_builtin(backend):
return (
backend.__module__.startswith('keyring.backends.') and
'chain' not in backend.__module__
)
keyring.core.init_backend(_only_builtin)
logger.debug('Keyring backend : %s', keyring.get_keyring())
def get_keyring():
try:
from ..signatures import keys
import keyring
assert keyring.get_keyring().priority
except (ImportError, AssertionError):
raise WheelError(
"Install wheel[signatures] (requires keyring, keyrings.alt, pyxdg) for signatures.")
return keys.WheelKeys, keyring
# keyring and secretstorage have to be importable
import keyring, secretstorage
if ("SecretService") in dir(keyring.backends) and not (keyring.get_keyring() is None):
return True
else:
# safety first - if not yet available disable it
#if not self.__dict__.has_key("use_system_keyring"):
if not 'use_system_keyring' in self.__dict__.keys():
self.use_system_keyring = False
# only import keyring lib if configured to do so
# necessary to avoid Windows crashes like https://github.com/HenriWahl/Nagstamon/issues/97
if self.use_system_keyring == True:
# hint for packaging: nagstamon.spec always have to match module path
# keyring has to be bound to object to be used later
import keyring
return not (keyring.get_keyring() is None)
else:
return False
except:
import traceback
traceback.print_exc(file=sys.stdout)
return False
def get_keyring():
try:
from ..signatures import keys
import keyring
assert keyring.get_keyring().priority
except (ImportError, AssertionError):
raise WheelError("Install wheel[signatures] (requires keyring, keyrings.alt, pyxdg) for signatures.")
return keys.WheelKeys, keyring