Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def has_keyczar():
with errors.ExceptionRaisedContext() as exc:
keyczar.__name__
return not bool(exc)
def _has_gdata(cls):
with ExceptionRaisedContext() as exc:
gdata.__name__
return not bool(exc)
def has_pyfs():
"""
Does this environment have pyfs installed?
Should return False even when Mercurial's Demand Import allowed import of
fs.*.
"""
with errors.ExceptionRaisedContext() as exc:
fs.__name__
return not bool(exc)
def has_wincrypto():
"""
Does this environment have wincrypto?
Should return False even when Mercurial's Demand Import allowed import of
_win_crypto, so accesses an attribute of the module.
"""
with ExceptionRaisedContext() as exc:
_win_crypto.__name__
return not bool(exc)
def has_pywin32():
"""
Does this environment have pywin32?
Should return False even when Mercurial's Demand Import allowed import of
win32cred.
"""
with ExceptionRaisedContext() as exc:
win32cred.__name__
return not bool(exc)
def viable(cls):
with ExceptionRaisedContext() as exc:
cls.priority
return not bool(exc)
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
return 5