mirror of
https://github.com/blw1138/Zordon.git
synced 2025-12-17 08:48:13 +00:00
Add JobNotFoundError and handlers to Flask to cleanup some methods
This commit is contained in:
@@ -16,6 +16,12 @@ JSON_FILE = 'server_state.json'
|
||||
#todo: move history to sqlite db
|
||||
|
||||
|
||||
class JobNotFoundError(Exception):
|
||||
def __init__(self, job_id, *args):
|
||||
super().__init__(args)
|
||||
self.job_id = job_id
|
||||
|
||||
|
||||
class RenderQueue:
|
||||
job_queue = []
|
||||
render_clients = []
|
||||
@@ -61,8 +67,10 @@ class RenderQueue:
|
||||
return found_jobs
|
||||
|
||||
@classmethod
|
||||
def job_with_id(cls, job_id):
|
||||
def job_with_id(cls, job_id, none_ok=False):
|
||||
found_job = next((x for x in cls.job_queue if x.id == job_id), None)
|
||||
if not found_job and not none_ok:
|
||||
raise JobNotFoundError(job_id)
|
||||
return found_job
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user