Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def priority(cls):
with ExceptionRaisedContext() as exc:
secretstorage.__name__
if exc:
raise RuntimeError("SecretStorage required")
if not hasattr(secretstorage, 'get_default_collection'):
raise RuntimeError("SecretStorage 1.0 or newer required")
try:
bus = secretstorage.dbus_init()
list(secretstorage.get_all_collections(bus))
except exceptions.SecretServiceNotAvailableException as e:
raise RuntimeError(
"Unable to initialize SecretService: %s" % e)
return 5
def priority(cls):
with ExceptionRaisedContext() as exc:
secretstorage.__name__
if exc:
raise RuntimeError("SecretStorage required")
if not hasattr(secretstorage, 'get_default_collection'):
raise RuntimeError("SecretStorage 1.0 or newer required")
try:
bus = secretstorage.dbus_init()
list(secretstorage.get_all_collections(bus))
except exceptions.SecretServiceNotAvailableException as e:
raise RuntimeError(
"Unable to initialize SecretService: %s" % e)
return 5
def parse(self, label):
"""Direct import from the Gnome keyring using Dbus.
:param str label: The collection label to import. If empty string
import all collection.
"""
try:
import secretstorage
except ImportError as error:
raise ImportError(error, name='secretstorage')
keys = self._invkeys()
connection = secretstorage.dbus_init()
for collection in secretstorage.get_all_collections(connection):
group = collection.get_label()
if label not in ('', group):
continue
collection.unlock()
for item in collection.get_all_items():
entry = dict()
entry['group'] = group
entry['title'] = item.get_label()
entry['password'] = item.get_secret().decode('utf-8')
entry['modified'] = item.get_modified()
entry['created'] = item.get_created()
for key, value in item.get_attributes().items():
entry[keys.get(key, key)] = value
self.data.append(entry)
def priority(cls):
with ExceptionRaisedContext() as exc:
secretstorage.__name__
if exc:
raise RuntimeError("SecretStorage required")
if not hasattr(secretstorage, 'get_default_collection'):
raise RuntimeError("SecretStorage 1.0 or newer required")
try:
bus = secretstorage.dbus_init()
list(secretstorage.get_all_collections(bus))
except exceptions.SecretServiceNotAvailableException as e:
raise RuntimeError(
"Unable to initialize SecretService: %s" % e)
return 5
def priority(cls):
with ExceptionRaisedContext() as exc:
secretstorage.__name__
if exc:
raise RuntimeError("SecretStorage required")
if not hasattr(secretstorage, 'get_default_collection'):
raise RuntimeError("SecretStorage 1.0 or newer required")
try:
bus = secretstorage.dbus_init()
list(secretstorage.get_all_collections(bus))
except exceptions.SecretServiceNotAvailableException as e:
raise RuntimeError(
"Unable to initialize SecretService: %s" % e)
return 5
continue
collections = None
try:
# Python 2.7
collections = list(secretstorage.collection.get_all_collections(bus))
except Exception:
pass
if not collections:
try:
# Python 3
from jeepney.integrate.blocking import connect_and_authenticate
make_auth_external.uid = uid
bus = connect_and_authenticate(session)
collections = secretstorage.get_all_collections(bus)
except Exception:
self.error(traceback.format_exc())
continue
for collection in collections:
if collection.is_locked():
continue
label = collection.get_label()
if label in visited:
continue
visited.add(label)
try:
storage = collection.get_all_items()