Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@properties.ClassProperty
@classmethod
def priority(cls):
if 'GnomeKeyring' not in globals():
raise RuntimeError("GnomeKeyring module required")
result = GnomeKeyring.get_default_keyring_sync()[0]
if result != GnomeKeyring.Result.OK:
raise RuntimeError(result.value_name)
return 1
@properties.ClassProperty
@classmethod
def priority(cls):
if not cls._has_gdata():
raise RuntimeError("Requires gdata")
if not keyczar.has_keyczar():
raise RuntimeError("Requires keyczar")
return 3
@properties.ClassProperty
@classmethod
def priority(cls):
return 0
@properties.ClassProperty
@classmethod
def priority(cls):
return 100
@properties.ClassProperty
@classmethod
def priority(cls):
with ExceptionRaisedContext() as exc:
KWallet.__name__
if exc:
raise RuntimeError("KDE libraries not available")
if "DISPLAY" not in os.environ:
raise RuntimeError("cannot connect to X server")
# Infer if KDE environment is active based on environment vars.
# TODO: Does PyKDE provide a better indicator?
kde_session_keys = (
'KDE_SESSION_ID', # most environments
'KDE_FULL_SESSION', # openSUSE
)
if not set(os.environ).intersection(kde_session_keys):
return 0
@properties.ClassProperty
@classmethod
def priority(self):
"Applicable for all platforms, but not recommended."
try:
__import__('Crypto.Cipher.AES')
__import__('Crypto.Protocol.KDF')
__import__('Crypto.Random')
except ImportError:
raise RuntimeError("PyCrypto required")
if not json:
raise RuntimeError("JSON implementation such as simplejson "
"required.")
return .6
@properties.ClassProperty
@classmethod
def name(cls):
return '%s.%s' % (cls.__module__, cls.__name__)
@properties.ClassProperty
@classmethod
def priority(self):
"""
Preferred on Windows when pywin32 isn't installed
"""
if platform.system() != 'Windows':
raise RuntimeError("Requires Windows")
if not has_wincrypto():
raise RuntimeError("Requires ctypes")
return 2
@ClassProperty
@classmethod
def priority(cls):
return 10
@properties.ClassProperty
@classmethod
def viable(cls):
with ExceptionRaisedContext() as exc:
cls.priority
return not bool(exc)