From 75ef471c26ac0cc2263e144c86b48cc6ca0d980b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romuald=20Texier-Marcad=C3=A9?= Date: Tue, 19 Dec 2023 14:47:10 +0100 Subject: [PATCH 1/4] cbor module unmaintained, replaced by cbor2. --- scripts/inspect_queue.py | 4 ++-- scripts/monitor.py | 2 +- scripts/publish_configuration.py | 2 +- scripts/publish_event.py | 2 +- scripts/send_command.py | 2 +- setup.py | 4 ++-- src/eventail/async_service/pika/base.py | 2 +- src/eventail/sync_publisher.py | 2 +- src/eventail/tmp_store.py | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/inspect_queue.py b/scripts/inspect_queue.py index a748967..595851c 100644 --- a/scripts/inspect_queue.py +++ b/scripts/inspect_queue.py @@ -26,7 +26,7 @@ import json import pprint -import cbor +import cbor2 as cbor import pika from pika.exceptions import ( @@ -57,7 +57,7 @@ def __init__(self, host, queue, count=0, save=False): def callback(self, ch, method, properties, body): decode = ( - json.loads if properties.content_type == "application/json" else cbor.loads + json.loads if properties.content_type == "application/json" else cbor2 as cbor.loads ) print("[{}]".format(method.routing_key)) pprint.pprint(properties) diff --git a/scripts/monitor.py b/scripts/monitor.py index d82dad8..e7bf656 100644 --- a/scripts/monitor.py +++ b/scripts/monitor.py @@ -27,7 +27,7 @@ import os import pprint -import cbor +import cbor2 as cbor from eventail.async_service.pika import Service diff --git a/scripts/publish_configuration.py b/scripts/publish_configuration.py index 4578073..b89bc14 100644 --- a/scripts/publish_configuration.py +++ b/scripts/publish_configuration.py @@ -26,7 +26,7 @@ import json import os.path -import cbor +import cbor2 as cbor from eventail.sync_publisher import Endpoint diff --git a/scripts/publish_event.py b/scripts/publish_event.py index 58e9135..f646072 100644 --- a/scripts/publish_event.py +++ b/scripts/publish_event.py @@ -28,7 +28,7 @@ import os.path import time -import cbor +import cbor2 as cbor import pika from eventail.async_service.pika import Service diff --git a/scripts/send_command.py b/scripts/send_command.py index 847cc8d..c7065a7 100644 --- a/scripts/send_command.py +++ b/scripts/send_command.py @@ -28,7 +28,7 @@ import pprint import os.path -import cbor +import cbor2 as cbor from eventail.async_service.pika import Service diff --git a/setup.py b/setup.py index 526af2c..9db4fbb 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name="eventail", - version="2.3.0", + version="2.3.1", url="https://github.com/allo-media/eventail", author="Allo-Media", author_email="dev@allo-media.fr", @@ -33,7 +33,7 @@ "scripts/resurrect.py", "scripts/send_command.py", ], - install_requires=["pika>=1.2.0", "cbor", "redis>=4.5.4"], + install_requires=["pika>=1.2.0", "cbor2", "redis>=4.5.4"], extras_require={ "synchronous": ["kombu"], "test": ["tox"], diff --git a/src/eventail/async_service/pika/base.py b/src/eventail/async_service/pika/base.py index 8ec81f8..d1b8f38 100644 --- a/src/eventail/async_service/pika/base.py +++ b/src/eventail/async_service/pika/base.py @@ -38,7 +38,7 @@ from contextlib import AbstractContextManager from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union -import cbor +import cbor2 as cbor import pika from eventail.gelf import GELF diff --git a/src/eventail/sync_publisher.py b/src/eventail/sync_publisher.py index d19ef44..9098ea8 100644 --- a/src/eventail/sync_publisher.py +++ b/src/eventail/sync_publisher.py @@ -29,7 +29,7 @@ import socket from typing import Any, Dict, List, Optional -import cbor +import cbor2 as cbor from kombu import Connection, Exchange from kombu.pools import producers, set_limit diff --git a/src/eventail/tmp_store.py b/src/eventail/tmp_store.py index 058fa6a..cbe458e 100644 --- a/src/eventail/tmp_store.py +++ b/src/eventail/tmp_store.py @@ -28,7 +28,7 @@ from typing import Any, Callable, Dict, List, Optional, Tuple from uuid import uuid4 -import cbor +import cbor2 as cbor import redis import redis.sentinel from redis.exceptions import ConnectionError, RedisError From ac42b4c9fa72a275e7a7199ccd8268fc2d91a77f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romuald=20Texier-Marcad=C3=A9?= Date: Tue, 19 Dec 2023 14:49:39 +0100 Subject: [PATCH 2/4] typo --- scripts/inspect_queue.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/inspect_queue.py b/scripts/inspect_queue.py index 595851c..653e24c 100644 --- a/scripts/inspect_queue.py +++ b/scripts/inspect_queue.py @@ -57,7 +57,7 @@ def __init__(self, host, queue, count=0, save=False): def callback(self, ch, method, properties, body): decode = ( - json.loads if properties.content_type == "application/json" else cbor2 as cbor.loads + json.loads if properties.content_type == "application/json" else cbor.loads ) print("[{}]".format(method.routing_key)) pprint.pprint(properties) From be9236c5e75450d4ed4acb2e8b6760a8138cd015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romuald=20Texier-Marcad=C3=A9?= Date: Tue, 19 Dec 2023 14:58:41 +0100 Subject: [PATCH 3/4] mypy is dumb --- scripts/publish_configuration.py | 2 +- scripts/publish_event.py | 2 +- scripts/send_command.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/publish_configuration.py b/scripts/publish_configuration.py index b89bc14..2f61b50 100644 --- a/scripts/publish_configuration.py +++ b/scripts/publish_configuration.py @@ -48,7 +48,7 @@ unserialize = json.loads if ext == ".json" else cbor.loads with open(args.payload, "rb") as ins: data = ins.read() - payload = unserialize(data) + payload = unserialize(data) # type: ignore endpoint = Endpoint(args.amqp_url, "debug_configuration_event_publisher") endpoint.publish_configuration(args.event, payload) diff --git a/scripts/publish_event.py b/scripts/publish_event.py index f646072..ea05090 100644 --- a/scripts/publish_event.py +++ b/scripts/publish_event.py @@ -82,7 +82,7 @@ def on_delivery_confirmation(self, method_frame: pika.frame.Method) -> None: unserialize = json.loads if ext == ".json" else cbor.loads with open(args.payload, "rb") as ins: data = ins.read() - payload = unserialize(data) + payload = unserialize(data) # type: ignore event_sender = EventSender( [args.amqp_url], args.event, payload, use_json=ext == "json" ) diff --git a/scripts/send_command.py b/scripts/send_command.py index c7065a7..6faae59 100644 --- a/scripts/send_command.py +++ b/scripts/send_command.py @@ -98,6 +98,6 @@ def handle_result( unserialize = json.loads if ext == ".json" else cbor.loads with open(args.payload, "rb") as ins: data = ins.read() - payload = unserialize(data) + payload = unserialize(data) # type: ignore rpc = RPC([args.amqp_url], args.command, payload, use_json=ext == "json") rpc.run() From 3f10e31d96f57add9a69d4a68cc1ff93199ac457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romuald=20Texier-Marcad=C3=A9?= Date: Tue, 19 Dec 2023 15:34:33 +0100 Subject: [PATCH 4/4] PEP8 --- scripts/publish_configuration.py | 2 +- scripts/publish_event.py | 2 +- scripts/send_command.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/publish_configuration.py b/scripts/publish_configuration.py index 2f61b50..e9fc048 100644 --- a/scripts/publish_configuration.py +++ b/scripts/publish_configuration.py @@ -48,7 +48,7 @@ unserialize = json.loads if ext == ".json" else cbor.loads with open(args.payload, "rb") as ins: data = ins.read() - payload = unserialize(data) # type: ignore + payload = unserialize(data) # type: ignore endpoint = Endpoint(args.amqp_url, "debug_configuration_event_publisher") endpoint.publish_configuration(args.event, payload) diff --git a/scripts/publish_event.py b/scripts/publish_event.py index ea05090..557b886 100644 --- a/scripts/publish_event.py +++ b/scripts/publish_event.py @@ -82,7 +82,7 @@ def on_delivery_confirmation(self, method_frame: pika.frame.Method) -> None: unserialize = json.loads if ext == ".json" else cbor.loads with open(args.payload, "rb") as ins: data = ins.read() - payload = unserialize(data) # type: ignore + payload = unserialize(data) # type: ignore event_sender = EventSender( [args.amqp_url], args.event, payload, use_json=ext == "json" ) diff --git a/scripts/send_command.py b/scripts/send_command.py index 6faae59..51026f5 100644 --- a/scripts/send_command.py +++ b/scripts/send_command.py @@ -98,6 +98,6 @@ def handle_result( unserialize = json.loads if ext == ".json" else cbor.loads with open(args.payload, "rb") as ins: data = ins.read() - payload = unserialize(data) # type: ignore + payload = unserialize(data) # type: ignore rpc = RPC([args.amqp_url], args.command, payload, use_json=ext == "json") rpc.run()