tidy up & black
This commit is contained in:
parent
15a5687bac
commit
7b66bcaafe
@ -65,8 +65,10 @@ def make_callback_for_output_queue(json_wrapped_body_processor, output_queue_nam
|
||||
if not CONFIG.service.response.save:
|
||||
channel.basic_publish(exchange="", routing_key=output_queue_name, body=result)
|
||||
else:
|
||||
upload_compressed_response(get_storage(CONFIG.storage.backend), CONFIG.storage.bucket, dossier_id, file_id, result)
|
||||
result = json.dumps({"dossierId" : dossier_id, "fileId" : file_id})
|
||||
upload_compressed_response(
|
||||
get_storage(CONFIG.storage.backend), CONFIG.storage.bucket, dossier_id, file_id, result
|
||||
)
|
||||
result = json.dumps({"dossierId": dossier_id, "fileId": file_id})
|
||||
channel.basic_publish(exchange="", routing_key=output_queue_name, body=result)
|
||||
|
||||
channel.basic_ack(delivery_tag=method.delivery_tag)
|
||||
|
||||
@ -13,6 +13,7 @@ def get_azure_storage(config=None):
|
||||
def get_s3_storage(config=None):
|
||||
return Storage(S3StorageAdapter(get_s3_client(config)))
|
||||
|
||||
|
||||
def get_storage(storage_backend):
|
||||
|
||||
if storage_backend == "s3":
|
||||
@ -22,4 +23,4 @@ def get_storage(storage_backend):
|
||||
else:
|
||||
raise UnknownStorageBackend(f"Unknown storage backend '{storage_backend}'.")
|
||||
|
||||
return storage
|
||||
return storage
|
||||
|
||||
@ -1,12 +1,7 @@
|
||||
"""Defines utilities for different operations on files."""
|
||||
|
||||
import gzip
|
||||
from io import BytesIO, StringIO
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
from pyinfra.config import CONFIG
|
||||
|
||||
@ -26,4 +21,4 @@ def dossier_id_and_file_id_to_compressed_storage_pdf_object_name(dossier_id, fil
|
||||
def upload_compressed_response(storage, bucket_name, dossier_id, file_id, result) -> None:
|
||||
data = gzip.compress(result.encode())
|
||||
path_gz = f"{dossier_id}/{file_id}{CONFIG.service.response.extension}"
|
||||
storage.put_object(bucket_name, path_gz, data)
|
||||
storage.put_object(bucket_name, path_gz, data)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user