Apply linting

This commit is contained in:
n07070
2026-05-21 02:57:27 +02:00
parent c50922790d
commit 2daafe28f2
8 changed files with 209 additions and 155 deletions

View File

@@ -1,6 +1,8 @@
# This class has the method by which we manage the Tasks
# It's a printing queue, so we need to add, remove and get information on where
# the queue is
"""
This class has the method by which we manage the Tasks
It's a printing queue, so we need to add, remove and get information on where
the queue is
"""
from collections import deque
@@ -9,12 +11,14 @@ from collections import deque
import threading
from datetime import datetime
from task import TaskType, CutTask
from task import TaskType
class PrintQueue:
"""
A Double-ended Queue to manage the printing Tasks
"""
def __init__(self, app):
self.app = app
self._queue = deque()
@@ -34,7 +38,11 @@ class PrintQueue:
self._queue.append(task)
position = self._queue.index(task)
# We return the current position of the task if it was added
self.app.logger.debug("Added a new task %s to the queue at position %s", task.task_id, position)
self.app.logger.debug(
"Added a new task %s to the queue at position %s",
task.task_id,
position,
)
return position
except Exception as e:
self.app.logger.error("Could not add a task to the queue : %s ", e)
@@ -85,32 +93,32 @@ class PrintQueue:
return {
"task_id": task_id,
"status": task.status,
"type" : task.task_type,
"type": task.task_type,
"position": index,
"in_queue": True,
"content" : task.content,
"signature": task.signature
"content": task.content,
"signature": task.signature,
}
if task.task_type == TaskType.TEXT:
return {
"task_id": task_id,
"status": task.status,
"type" : task.task_type,
"type": task.task_type,
"position": index,
"in_queue": True,
"image_path" : str(task.image_path),
"signature" : task.signature,
"process" : str(task.process)
"image_path": str(task.image_path),
"signature": task.signature,
"process": str(task.process),
}
if task.task_type == TaskType.CUT:
return {
"task_id": task_id,
"status": task.status,
"type" : task.task_type,
"type": task.task_type,
"position": index,
"in_queue": True
"in_queue": True,
}
return None
@@ -123,5 +131,5 @@ class PrintQueue:
"status": task_status,
"position": None,
"in_queue": False,
"completed_at": datetime.now().isoformat()
}
"completed_at": datetime.now().isoformat(),
}