Compare commits
No commits in common. "main" and "asdfasdfdasd" have entirely different histories.
main
...
asdfasdfda
22
app.py
22
app.py
@ -4,31 +4,23 @@ import threading
|
||||
import queue
|
||||
import pdf2image
|
||||
from brother_ql.conversion import convert
|
||||
from brother_ql.backends.helpers import send, status
|
||||
from brother_ql.backends.helpers import send
|
||||
from brother_ql.raster import BrotherQLRaster
|
||||
from PIL import Image
|
||||
import mimetypes
|
||||
import logging
|
||||
from logging.handlers import RotatingFileHandler
|
||||
import time
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
# Set up logging
|
||||
log_file = 'log.txt'
|
||||
|
||||
# Create a rotating file handler for logging
|
||||
log_handler = RotatingFileHandler(log_file, maxBytes=10*1024*1024, backupCount=5) # 10MB per log file, keep 5 backups
|
||||
log_handler.setLevel(logging.DEBUG)
|
||||
log_handler.setLevel(logging.INFO)
|
||||
log_formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
|
||||
log_handler.setFormatter(log_formatter)
|
||||
|
||||
# Add the log handler to the Flask app's logger
|
||||
app.logger.addHandler(log_handler)
|
||||
|
||||
# Ensure Flask app uses our logger, not its default one
|
||||
app.logger.setLevel(logging.DEBUG)
|
||||
|
||||
# Create a queue to hold the files for processing
|
||||
file_queue = queue.Queue()
|
||||
|
||||
@ -62,13 +54,6 @@ def print_address_label(pdf_path):
|
||||
if not image:
|
||||
raise Exception("Failed to create label images")
|
||||
|
||||
if 'address' in pdf_path.lower():
|
||||
target_width = 1660
|
||||
target_height = 1164
|
||||
image = image.convert("RGB")
|
||||
image = image.resize((target_width, target_height), Image.LANCZOS)
|
||||
image = image.rotate(90, expand=True)
|
||||
else:
|
||||
target_width = 1164
|
||||
target_height = 1660
|
||||
image = image.convert("RGB")
|
||||
@ -92,13 +77,12 @@ def print_address_label(pdf_path):
|
||||
)
|
||||
|
||||
app.logger.info("Sending to printer...")
|
||||
status = send(
|
||||
send(
|
||||
instructions=instructions,
|
||||
printer_identifier=printer,
|
||||
backend_identifier=backend,
|
||||
blocking=True
|
||||
)
|
||||
app.logger.info(f"Printer status: {status}")
|
||||
app.logger.info("Print job sent successfully")
|
||||
|
||||
except Exception as e:
|
||||
|
Loading…
x
Reference in New Issue
Block a user