How to use the jeepney.wrappers.DBusErrorResponse function in jeepney

To help you get started, we’ve selected a few jeepney examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mitya57 / secretstorage / secretstorage / util.py View on Github external
def open_session(connection: DBusConnection) -> Session:
	"""Returns a new Secret Service session."""
	service = DBusAddressWrapper(SS_PATH, SERVICE_IFACE, connection)
	session = Session()
	try:
		output, result = service.call('OpenSession', 'sv',
			ALGORITHM_DH,
			('ay', int_to_bytes(session.my_public_key)))
	except DBusErrorResponse as resp:
		if resp.name != DBUS_NOT_SUPPORTED:
			raise
		output, result = service.call('OpenSession', 'sv',
			ALGORITHM_PLAIN,
			('s', ''))
		session.encrypted = False
	else:
		signature, value = output
		assert signature == 'ay'
		key = int_from_bytes(value, 'big')
		session.set_server_public_key(key)
	session.object_path = result
	return session