From 7b66bcaafe32e80a64ad09ef424c28fe1f73cd23 Mon Sep 17 00:00:00 2001 From: Julius Unverfehrt Date: Mon, 28 Feb 2022 15:22:19 +0100 Subject: [PATCH] tidy up & black --- pyinfra/callback.py | 6 ++++-- pyinfra/storage/storages.py | 3 ++- pyinfra/utils/file.py | 7 +------ 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/pyinfra/callback.py b/pyinfra/callback.py index a503ec5..5684bec 100644 --- a/pyinfra/callback.py +++ b/pyinfra/callback.py @@ -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) diff --git a/pyinfra/storage/storages.py b/pyinfra/storage/storages.py index bf6534c..2e58186 100644 --- a/pyinfra/storage/storages.py +++ b/pyinfra/storage/storages.py @@ -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 \ No newline at end of file + return storage diff --git a/pyinfra/utils/file.py b/pyinfra/utils/file.py index bb74da9..2d33f35 100644 --- a/pyinfra/utils/file.py +++ b/pyinfra/utils/file.py @@ -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) \ No newline at end of file + storage.put_object(bucket_name, path_gz, data)