debug scripts
This commit is contained in:
Executable
+89
@@ -0,0 +1,89 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test script to render the library view and save it as PNG.
|
||||
This helps verify the rendering is working correctly.
|
||||
"""
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# Add parent directory to path
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||
|
||||
from dreader.library import LibraryManager
|
||||
|
||||
|
||||
def main():
|
||||
"""Test library rendering and save as PNG."""
|
||||
|
||||
library_path = "tests/data/library-epub"
|
||||
output_path = "library_render_test.png"
|
||||
|
||||
print("=" * 60)
|
||||
print("Library Rendering Test")
|
||||
print("=" * 60)
|
||||
print(f"Library path: {library_path}")
|
||||
print(f"Output file: {output_path}")
|
||||
print()
|
||||
|
||||
# Create library manager
|
||||
print("Creating library manager...")
|
||||
library = LibraryManager(
|
||||
library_path=library_path,
|
||||
page_size=(1872, 1404)
|
||||
)
|
||||
|
||||
# Scan library
|
||||
print("Scanning library...")
|
||||
library.scan_library()
|
||||
|
||||
print()
|
||||
print(f"Found {len(library.books)} books:")
|
||||
for book in library.books:
|
||||
print(f" - {book['title']} by {book['author']}")
|
||||
print()
|
||||
|
||||
# Create library table (renders the first page)
|
||||
print("Creating library table (page 1)...")
|
||||
library.create_library_table(page=0)
|
||||
|
||||
# Render the table
|
||||
print("Rendering library view...")
|
||||
image = library.render_library()
|
||||
|
||||
if image:
|
||||
print(f"Image size: {image.size}")
|
||||
print(f"Image mode: {image.mode}")
|
||||
|
||||
# Save as PNG
|
||||
print(f"Saving to {output_path}...")
|
||||
image.save(output_path)
|
||||
|
||||
print()
|
||||
print("=" * 60)
|
||||
print("SUCCESS!")
|
||||
print("=" * 60)
|
||||
print(f"Library view saved to: {output_path}")
|
||||
print()
|
||||
print("You can view the image with:")
|
||||
print(f" xdg-open {output_path} # Linux")
|
||||
print(f" open {output_path} # macOS")
|
||||
print()
|
||||
|
||||
return 0
|
||||
else:
|
||||
print()
|
||||
print("=" * 60)
|
||||
print("ERROR: No image rendered")
|
||||
print("=" * 60)
|
||||
return 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
sys.exit(main())
|
||||
except Exception as e:
|
||||
print(f"\nERROR: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
sys.exit(1)
|
||||
Reference in New Issue
Block a user