Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
with closing(dbus_init()) as conn:
collection = secretstorage.get_default_collection(conn)
items = collection.search_items({'application': 'myapp'})
However, you will not be able to call any methods on the objects
created within the context after you leave it.
.. versionchanged:: 3.0
Before the port to Jeepney, this function returned an
instance of :class:`dbus.SessionBus` class.
.. versionchanged:: 3.1
This function no longer accepts any arguments.
"""
try:
connection = connect_and_authenticate()
add_match_rules(connection)
return connection
except KeyError as ex:
# os.environ['DBUS_SESSION_BUS_ADDRESS'] may raise it
reason = "Environment variable {} is unset".format(ex.args[0])
raise SecretServiceNotAvailableException(reason) from ex
except (ConnectionError, ValueError) as ex:
raise SecretServiceNotAvailableException(str(ex)) from ex
self.error(traceback.format_exc())
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: