Improve CSV Logging and Fix Image Import Handling - #197
Open
hmshuv wants to merge 5 commits into
Open
Conversation
for more information, see https://pre-commit.ci
…shuv/wagtail-wordpress-import into fix/logging-and-image-imports
Author
|
I've resolved the pre-commit CI failures. isort needed a version bump to fix a build error with newer tools, and I fixed a few legacy syntax issues (backticks) caught by flake8. All checks are passing now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Improve CSV Logging and Fix Image Import Handling
Closes #193
Closes #142
Closes #145
Closes #171
Description
This PR addresses the "Make the logging to CSV better" issue and resolves several sub-issues related to failures and missing logs during image import.
Key Changes:
Refactored CSV Logging (logger.py):
self.images(causing incorrect data or crashes) instead ofself.page_link_errors. It now correctly extracts and logs page link errors.Robust Image Import Handling:
None) instead of crashing with anAttributeError. A fallback HTML comment is now generated in the stream block.get_or_save_imagecan fail if the downloaded image's is corrupted #145 (Corrupted Image): Wrapped the image save operation in get_or_save_image with atry/exceptblock to catchIntegrityError(e.g., width=0) or other exceptions caused by corrupted files.Testing & Verification
I have verified these changes using custom reproduction scripts to simulate the failure scenarios:
pagelink_errors-report.csvnow contains the correct data for broken links.images-report.csv.Checklist
get_or_save_imagecan fail if the downloaded image's is corrupted #145, Images Won't Import #171 resolved