mirror of
https://github.com/blw1138/Zordon.git
synced 2025-12-17 16:58:12 +00:00
Convert render_queue and scheduledjob to use sql instead of json
This commit is contained in:
@@ -49,7 +49,7 @@ def index():
|
||||
with open('config/presets.yaml') as f:
|
||||
presets = yaml.load(f, Loader=yaml.FullLoader)
|
||||
|
||||
return render_template('index.html', all_jobs=sorted_jobs(RenderQueue.job_queue),
|
||||
return render_template('index.html', all_jobs=sorted_jobs(RenderQueue.all_jobs()),
|
||||
hostname=RenderQueue.host_name, renderer_info=renderer_info(),
|
||||
render_clients=RenderQueue.render_clients, preset_list=presets)
|
||||
|
||||
@@ -101,7 +101,7 @@ def get_job_file(job_id, filename):
|
||||
|
||||
@server.get('/api/jobs')
|
||||
def jobs_json():
|
||||
return [x.json() for x in RenderQueue.job_queue]
|
||||
return [x.json() for x in RenderQueue.all_jobs()]
|
||||
|
||||
|
||||
@server.get('/api/jobs/<status_val>')
|
||||
@@ -127,7 +127,7 @@ def get_job_status(job_id):
|
||||
@server.get('/api/job/<job_id>/logs')
|
||||
def get_job_logs(job_id):
|
||||
found_job = RenderQueue.job_with_id(job_id)
|
||||
log_path = found_job.worker.log_path
|
||||
log_path = found_job.log_path()
|
||||
log_data = None
|
||||
if log_path and os.path.exists(log_path):
|
||||
with open(log_path) as file:
|
||||
@@ -151,9 +151,9 @@ def download_all(job_id):
|
||||
return response
|
||||
|
||||
found_job = RenderQueue.job_with_id(job_id)
|
||||
output_dir = os.path.dirname(found_job.worker.output_path)
|
||||
output_dir = os.path.dirname(found_job.output_path)
|
||||
if os.path.exists(output_dir):
|
||||
zip_filename = os.path.join('/tmp', pathlib.Path(found_job.worker.input_path).stem + '.zip')
|
||||
zip_filename = os.path.join('/tmp', pathlib.Path(found_job.input_path).stem + '.zip')
|
||||
with ZipFile(zip_filename, 'w') as zipObj:
|
||||
for f in os.listdir(output_dir):
|
||||
zipObj.write(filename=os.path.join(output_dir, f),
|
||||
@@ -219,7 +219,7 @@ def full_status():
|
||||
@server.get('/api/snapshot')
|
||||
def snapshot():
|
||||
server_status = RenderQueue.status()
|
||||
server_jobs = [x.json() for x in RenderQueue.job_queue]
|
||||
server_jobs = [x.json() for x in RenderQueue.all_jobs()]
|
||||
server_data = {'status': server_status, 'jobs': server_jobs, 'timestamp': datetime.now().isoformat()}
|
||||
return server_data
|
||||
|
||||
@@ -405,7 +405,7 @@ def delete_job(job_id):
|
||||
os.remove(thumb_path)
|
||||
|
||||
# See if we own the input file (i.e. was it uploaded)
|
||||
input_dir = os.path.dirname(found_job.worker.input_path)
|
||||
input_dir = os.path.dirname(found_job.input_path)
|
||||
if server.config['UPLOAD_FOLDER'] in input_dir and os.path.exists(input_dir):
|
||||
shutil.rmtree(input_dir)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user