Update linting with black

This commit is contained in:
n07070
2026-05-17 14:24:07 +02:00
parent 641b8a2d1f
commit 85c10a47b0
4 changed files with 214 additions and 117 deletions

View File

@@ -4,10 +4,11 @@ from printer import Printer
import time
import os
class Web(object):
"""docstring for web."""
def __init__(self, app, printer ):
def __init__(self, app, printer):
super(Web).__init__()
self.printer = printer
self.app = app
@@ -20,10 +21,9 @@ class Web(object):
self.printer.cut()
except Exception as e:
self.app.logger.error(e)
flash("Error while printing the SMS : "+ str(e))
flash("You message " + str( texte ) + " has been printed :)")
flash("Error while printing the SMS : " + str(e))
flash("You message " + str(texte) + " has been printed :)")
def print_image(self, image, sign):
self.app.logger.debug("Uploading file")
@@ -31,7 +31,14 @@ class Web(object):
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=sign,process=True)
self.printer.print_img(
os.path.join(
self.app.config["UPLOAD_FOLDER"],
secure_filename(image.filename),
),
sign=sign,
process=True,
)
self.printer.cut()
except Exception as e:
self.app.logger.error(e)
@@ -39,7 +46,7 @@ class Web(object):
flash("Your image has been printed :)")
def login(username: str,password: str) -> bool:
def login(username: str, password: str) -> bool:
pass
def logout(username: str, password: str) -> bool:
@@ -47,22 +54,29 @@ class Web(object):
def allowed_file(self, filename) -> bool:
self.app.logger.debug("Is the filename allowed ?")
return '.' in filename and filename.rsplit('.', 1)[1].lower() in self.app.config['ALLOWED_EXTENSIONS']
return (
"." in filename
and filename.rsplit(".", 1)[1].lower()
in self.app.config["ALLOWED_EXTENSIONS"]
)
def upload_file(self, image)-> bool:
def upload_file(self, image) -> bool:
self.app.logger.debug("Validating file")
if image and self.allowed_file(image.filename):
filename = secure_filename(image.filename)
self.app.logger.debug("File valid")
try:
image.save(os.path.join(self.app.config['UPLOAD_FOLDER'], filename))
image.save(os.path.join(self.app.config["UPLOAD_FOLDER"], filename))
self.app.logger.debug("File saved")
except Exception as e:
self.app.logger.error("Could not save file")
flash(str(e),'error')
flash(str(e), "error")
return False
self.app.logger.debug("File saved to " + str(os.path.join(self.app.config['UPLOAD_FOLDER'], filename)))
self.app.logger.debug(
"File saved to "
+ str(os.path.join(self.app.config["UPLOAD_FOLDER"], filename))
)
return True
else:
self.app.logger.error("Could not save file " + str(filename))