From 24a2d9c24c67296c333009f5bbea71b0a78a4dd8 Mon Sep 17 00:00:00 2001 From: Eric Rich Date: Wed, 21 Feb 2024 13:48:26 -0500 Subject: [PATCH] Providing a minor change to where the from_http and to_binary methods/functions come from. (#28) fix: use CloudEvent appropriately Without this you will see messages like the following: ``` deprecation.DeprecatedWarning: to_binary is deprecated as of 1.6.0. Use cloudevents.conversion.to_binary function instead caught to_binary is deprecated as of 1.6.0. Use cloudevents.conversion.to_binary function instead Function raised to_binary is deprecated as of 1.6.0. Use cloudevents.conversion.to_binary function instead ``` --- parliament/server.py | 8 +++++--- tests/event/event_test.py | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/parliament/server.py b/parliament/server.py index 37f18e4..b9b25b1 100644 --- a/parliament/server.py +++ b/parliament/server.py @@ -4,7 +4,8 @@ import logging from flask import Flask, request -from cloudevents.http import CloudEvent, from_http, to_binary +from cloudevents.http import CloudEvent +from cloudevents.conversion import from_http, to_binary from .invocation import Context @@ -29,10 +30,11 @@ def create(func): def handle_post(): context = Context(request) try: - context.cloud_event = from_http(request.headers, + context.cloud_event = from_http(CloudEvent, request.headers, request.get_data()) - except Exception: + except Exception as e: app.logger.warning('No CloudEvent available') + app.logger.exception(e) app.logger.exception(traceback.print_exc()) return invoke(func, context) diff --git a/tests/event/event_test.py b/tests/event/event_test.py index 132faa6..901b6cf 100644 --- a/tests/event/event_test.py +++ b/tests/event/event_test.py @@ -1,4 +1,5 @@ -from cloudevents.http import CloudEvent, to_binary +from cloudevents.http import CloudEvent +from cloudevents.conversion import to_binary def test_post_cloud_event(client):