removed obsolete code
This commit is contained in:
parent
d96671504d
commit
81a55e8622
@ -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(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user