From 411d07eaa2cd72147b280b41ed95892009e0292e Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Thu, 16 May 2024 04:49:06 +0100 Subject: Cleans up a few LSP errors --- pyblackbird_cc/resources/views.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'pyblackbird_cc/resources/views.py') diff --git a/pyblackbird_cc/resources/views.py b/pyblackbird_cc/resources/views.py index e96e701..91f2728 100644 --- a/pyblackbird_cc/resources/views.py +++ b/pyblackbird_cc/resources/views.py @@ -94,8 +94,8 @@ def _extract_metadata_from_resource(resource_obj) -> ResourceInfo | None: created=resource_obj.created_at, updated=resource_obj.updated_at, ) - except Exception as e: - logging.exception(f"Error extracting resource information: {e}") + except Exception: + logging.exception("Error extracting resource information") return None @@ -123,7 +123,7 @@ def get_presigned_obj_url(bucket_name, obj_name, expiration=3600) -> str | None: ExpiresIn=expiration, ) except ClientError as e: - logger.error(e) + logger.exception("Error generating presigned URL", extra={"error": e}) return None return response @@ -140,14 +140,14 @@ def upload_to_s3(pdf_files, thumbnail_files, snappedshotted_pages) -> bool: try: for pdf_file in pdf_files: - logger.info(f"Uploading {pdf_file.name} to S3") + logger.info("Uploading {pdf_file.name} to S3") client.upload_fileobj( pdf_file, settings.AWS_STORAGE_BUCKET_NAME, f"pdfuploads/{pdf_file.name}", ) for f in thumbnail_files: - logger.info(f"Uploading {f.name} to S3") + logger.info("Uploading {f.name} to S3") client.upload_fileobj( f, settings.AWS_STORAGE_BUCKET_NAME, @@ -155,7 +155,7 @@ def upload_to_s3(pdf_files, thumbnail_files, snappedshotted_pages) -> bool: ) if len(snappedshotted_pages[0]) == 1: for img in snappedshotted_pages[0]: - logger.info(f"Uploading {img} to S3") + logger.info("Uploading {img} to S3") client.upload_file( img, settings.AWS_STORAGE_BUCKET_NAME, @@ -164,15 +164,15 @@ def upload_to_s3(pdf_files, thumbnail_files, snappedshotted_pages) -> bool: else: for lst in snappedshotted_pages: for img in lst: - logger.info(f"Uploading {img} to S3") + logger.info("Uploading {img} to S3") client.upload_file( img, settings.AWS_STORAGE_BUCKET_NAME, f"snapshotted_pages/{os.path.basename(img)}", ) return True - except ClientError as e: - logging.exception(f"Error uploading files to S3: {e}") + except ClientError: + logging.exception("Error uploading files to S3") return False @@ -280,8 +280,8 @@ def create_resource(request): raise Exception("Error uploading files to S3") return redirect("resources:resource_detail", resource_id=resource.id) - except Exception as e: - logger.error(f"Error creating resource: {e}") + except Exception: + logger.exception("Error creating resource") form.add_error(None, "An error occurred while creating the resource.") else: # extract form errors -- cgit v1.2.3