kind of a mess lol but file caching and front end

This commit is contained in:
2025-04-17 13:28:49 -04:00
parent 21408af48c
commit 8f35cedb4a
45 changed files with 1435 additions and 1316 deletions

View File

@ -9,6 +9,7 @@ import asyncio
import time
from PIL import Image
from contextlib import asynccontextmanager
from app.schemas.file import FileInDB
logger = logging.getLogger(__name__)
@ -141,11 +142,11 @@ class LabelPrinterService:
logger.error(f"Unexpected error in _send_print_request: {e}")
return False
async def print_file(self, file_path: Union[str, Path], label_size: Literal["dk1201", "dk1241"], label_type: Optional[Literal["address_label", "packing_slip", "set_label"]] = None) -> bool:
async def print_file(self, file_path: Union[str, Path, FileInDB], label_size: Literal["dk1201", "dk1241"], label_type: Optional[Literal["address_label", "packing_slip", "set_label"]] = None) -> bool:
"""Print a PDF or PNG file to the label printer.
Args:
file_path: Path to the PDF or PNG file
file_path: Path to the PDF or PNG file, or a FileInDB object
label_size: Size of label to use ("dk1201" or "dk1241")
label_type: Type of label to use ("address_label" or "packing_slip" or "set_label")
@ -158,6 +159,10 @@ class LabelPrinterService:
logger.error("No file path provided")
return False
# Handle FileInDB objects
if isinstance(file_path, FileInDB):
file_path = file_path.path
file_path = Path(file_path)
if not file_path.exists():
logger.error(f"File not found: {file_path}")