Apply linting to web
This commit is contained in:
35
src/web.py
35
src/web.py
@@ -1,10 +1,13 @@
|
|||||||
|
"""
|
||||||
|
Manage all of the inputs from a web source
|
||||||
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from flask import flash
|
|
||||||
from werkzeug.utils import secure_filename
|
from werkzeug.utils import secure_filename
|
||||||
from task import TextTask, ImageTask, CutTask
|
from task import TextTask, ImageTask, CutTask
|
||||||
|
|
||||||
|
|
||||||
class Web(object):
|
class Web:
|
||||||
"""Web is the class that gets all of the information from web calls
|
"""Web is the class that gets all of the information from web calls
|
||||||
( API and Web page ) and provides checks before sending stuff to printing"""
|
( API and Web page ) and provides checks before sending stuff to printing"""
|
||||||
|
|
||||||
@@ -65,16 +68,19 @@ class Web(object):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def login(self, username: str, password: str) -> bool:
|
# def login(self, username: str, password: str) -> bool:
|
||||||
"""Not implemented"""
|
# """Not implemented"""
|
||||||
return
|
# return
|
||||||
|
|
||||||
def logout(self, username: str, password: str) -> bool:
|
# def logout(self, username: str, password: str) -> bool:
|
||||||
"""Not implemented"""
|
# """Not implemented"""
|
||||||
return
|
# return
|
||||||
|
|
||||||
def allowed_file(self, filename) -> bool:
|
def allowed_file(self, filename) -> bool:
|
||||||
self.app.logger.debug("Is the filename allowed ?")
|
"""
|
||||||
|
Check if the file extension is allowed
|
||||||
|
"""
|
||||||
|
self.app.logger.debug("Checking if the file extension is allowed")
|
||||||
return (
|
return (
|
||||||
"." in filename
|
"." in filename
|
||||||
and filename.rsplit(".", 1)[1].lower()
|
and filename.rsplit(".", 1)[1].lower()
|
||||||
@@ -82,8 +88,11 @@ class Web(object):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def upload_file(self, image) -> bool:
|
def upload_file(self, image) -> bool:
|
||||||
|
"""
|
||||||
|
Save the file after executing checks on it
|
||||||
|
"""
|
||||||
self.app.logger.debug("Validating file")
|
self.app.logger.debug("Validating file")
|
||||||
if image:
|
if not image is None or not image == "":
|
||||||
if self.allowed_file(image.filename):
|
if self.allowed_file(image.filename):
|
||||||
filename = secure_filename(image.filename)
|
filename = secure_filename(image.filename)
|
||||||
self.app.logger.debug("File valid")
|
self.app.logger.debug("File valid")
|
||||||
@@ -104,12 +113,6 @@ class Web(object):
|
|||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
else:
|
|
||||||
self.app.logger.error(
|
|
||||||
"Could not save file, it seems to be null ? : " + str(filename)
|
|
||||||
)
|
|
||||||
return False
|
|
||||||
|
|
||||||
def get_queue_state(self):
|
def get_queue_state(self):
|
||||||
"""Return current queue state"""
|
"""Return current queue state"""
|
||||||
return self.print_queue.get_queue_state()
|
return self.print_queue.get_queue_state()
|
||||||
|
|||||||
Reference in New Issue
Block a user