Update little printer requirements

This commit is contained in:
nono
2025-06-23 23:08:32 +02:00
committed by n07070
parent d4a9a059bf
commit 1a1c4e2fb3
8 changed files with 311 additions and 127 deletions

View File

@@ -1,4 +1,4 @@
from flask import Flask, request
from flask import Flask, request, flash
from werkzeug.utils import secure_filename
from printer import Printer
import time
@@ -15,28 +15,27 @@ class Web(object):
def print_sms(self, texte, sign: str):
# TODO: verify the texte before printing it here ?
self.app.logger.debug("Printing : " + str(texte) + " from " + str(sign))
if not os.getenv('LIPY_DEBUG'):
time.sleep(1)
try:
self.printer.print_sms(texte, sign)
except Exception as e:
self.app.logger.error(e)
flash("Error while printing the SMS : "+ str(e))
return self.printer.print_sms(texte, sign)
flash("You message has been printed :)")
def print_image(self, image, sign: str) -> bool:
def print_image(self, image, sign: str):
self.app.logger.debug("Uploading file")
try:
self.app.logger.debug("Uploading file from " + str(sign))
if self.upload_file(image):
self.app.logger.debug("File has been uploaded, printing...")
self.printer.print_img(os.path.join(self.app.config['UPLOAD_FOLDER'], secure_filename(image.filename)), sign)
return True
else:
return False
except Exception as e:
self.app.logger.error(e)
raise Exception
flash("Could not upload file." + str(e))
else:
flash("Could not upload file.",'error')
return False
flash("Your image has been printed :)")
def login(username: str,password: str) -> bool:
pass