From 81a55e8622cc539d70b7f821cbed80fda4ce3790 Mon Sep 17 00:00:00 2001 From: Matthias Bisping Date: Wed, 16 Feb 2022 17:18:29 +0100 Subject: [PATCH] removed obsolete code --- pyinfra/rabbitmq.py | 59 --------------------------------------------- 1 file changed, 59 deletions(-) diff --git a/pyinfra/rabbitmq.py b/pyinfra/rabbitmq.py index ea1819e..a13593a 100644 --- a/pyinfra/rabbitmq.py +++ b/pyinfra/rabbitmq.py @@ -1,14 +1,6 @@ -import json -import logging -import tempfile -import time -from operator import itemgetter - import pika from pyinfra.config import CONFIG -from pyinfra.utils.file import dossier_id_and_file_id_to_compressed_storage_pdf_object_name, download, unzip -from pyinfra.storage.minio import MinioHandle def make_channel(connection) -> pika.adapters.blocking_connection.BlockingChannel: @@ -26,57 +18,6 @@ def declare_queue(channel, queue: str): return channel.queue_declare(queue=queue, auto_delete=False, arguments=args, durable=True) -def make_dummy_callback(): - def callback(channel, method, properties, body): - logging.info(f" [R] Received {body}") - response = json.dumps(process(body)) - channel.basic_publish(exchange="", routing_key=CONFIG.rabbitmq.queues.output, body=response) - channel.basic_ack(delivery_tag=method.delivery_tag) - - def process(payload): - payload = json.loads(payload) - payload["imageMetadata"] = [] - return payload - - return callback - - -def make_callback(name): - if name == "storage_debug": - return make_storage_debug_callback() - elif name == "dummy": - return make_dummy_callback() - - -def make_storage_debug_callback(): - - storage_client = MinioHandle() - - def callback(channel, method, properties, body): - logging.info(f" [R] Received {body}") - response = json.dumps(process(body)) - channel.basic_publish(exchange="", routing_key=CONFIG.rabbitmq.queues.output, body=response) - channel.basic_ack(delivery_tag=method.delivery_tag) - - def process(payload): - payload = json.loads(payload) - with tempfile.TemporaryDirectory() as pdf_compressed_dir: - with tempfile.TemporaryDirectory() as pdf_dir: - - dossier_id, file_id = itemgetter("dossierId", "fileId")(payload) - time.sleep(0.4) - object_name = dossier_id_and_file_id_to_compressed_storage_pdf_object_name(dossier_id, file_id) - time.sleep(0.6) - downloaded_file_path = download(storage_client, object_name, pdf_compressed_dir) - time.sleep(0.3) - unzipped_file_path = unzip(downloaded_file_path, pdf_dir) - time.sleep(1) - payload["imageMetadata"] = [] - return json.dumps(payload) - - return callback - - def read_connection_params(): credentials = pika.PlainCredentials(CONFIG.rabbitmq.user, CONFIG.rabbitmq.password) parameters = pika.ConnectionParameters(