Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def on_suback(packet_id, topic_qos_tuples, error_code):
if error_code:
future.set_exception(awscrt.exceptions.from_code(error_code))
else:
future.set_result(dict(
packet_id=packet_id,
topics=[(topic, _try_qos(qos)) for (topic, qos) in topic_qos_tuples],
))
def on_connect(error_code, return_code, session_present):
if return_code:
future.set_exception(Exception(ConnectReturnCode(return_code)))
elif error_code:
future.set_exception(awscrt.exceptions.from_code(error_code))
else:
future.set_result(dict(session_present=session_present))
def _on_complete(error_code, access_key_id, secret_access_key, session_token):
try:
if error_code:
future.set_exception(awscrt.exceptions.from_code(error_code))
else:
credentials = AwsCredentials(access_key_id, secret_access_key, session_token)
future.set_result(credentials)
except Exception as e:
future.set_exception(e)
def on_connection_setup(binding, error_code):
if error_code == 0:
connection._binding = binding
future.set_result(connection)
else:
future.set_exception(awscrt.exceptions.from_code(error_code))
def _on_complete(self, error_code):
if error_code == 0:
self._completion_future.set_result(self._response_status_code)
else:
self._completion_future.set_exception(awscrt.exceptions.from_code(error_code))
def on_shutdown(error_code):
if error_code:
shutdown_future.set_exception(awscrt.exceptions.from_code(error_code))
else:
shutdown_future.set_result(None)
def _on_connection_interrupted(self, error_code):
if self._on_connection_interrupted_cb:
self._on_connection_interrupted_cb(connection=self, error=awscrt.exceptions.from_code(error_code))
def _on_complete(error_code):
try:
if error_code:
future.set_exception(awscrt.exceptions.from_code(error_code))
else:
future.set_result(http_request)
except Exception as e:
future.set_exception(e)