mirror of
https://github.com/blw1138/Zordon.git
synced 2025-12-17 08:48:13 +00:00
Add rest call to get job logs
This commit is contained in:
@@ -9,7 +9,7 @@ from datetime import datetime
|
|||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from flask import Flask, request, render_template, send_file, after_this_request
|
from flask import Flask, request, render_template, send_file, after_this_request, Response
|
||||||
from werkzeug.utils import secure_filename
|
from werkzeug.utils import secure_filename
|
||||||
|
|
||||||
from lib.render_job import RenderJob
|
from lib.render_job import RenderJob
|
||||||
@@ -44,6 +44,20 @@ def get_job_status(job_id):
|
|||||||
return f'Cannot find job with ID {job_id}', 400
|
return f'Cannot find job with ID {job_id}', 400
|
||||||
|
|
||||||
|
|
||||||
|
@server.get('/api/job/<job_id>/logs')
|
||||||
|
def get_job_logs(job_id):
|
||||||
|
found_job = RenderQueue.job_with_id(job_id)
|
||||||
|
if found_job:
|
||||||
|
log_path = found_job.worker.log_path
|
||||||
|
log_data = None
|
||||||
|
if log_path and os.path.exists(log_path):
|
||||||
|
with open(log_path) as file:
|
||||||
|
log_data = file.read()
|
||||||
|
return Response(log_data, mimetype='text/plain')
|
||||||
|
else:
|
||||||
|
return f'Cannot find job with ID {job_id}', 400
|
||||||
|
|
||||||
|
|
||||||
@server.get('/api/file_list/<job_id>')
|
@server.get('/api/file_list/<job_id>')
|
||||||
def get_file_list(job_id):
|
def get_file_list(job_id):
|
||||||
found_job = RenderQueue.job_with_id(job_id)
|
found_job = RenderQueue.job_with_id(job_id)
|
||||||
|
|||||||
@@ -81,6 +81,22 @@ class RenderJob:
|
|||||||
def stop(self):
|
def stop(self):
|
||||||
self.worker.stop()
|
self.worker.stop()
|
||||||
|
|
||||||
|
def time_elapsed(self):
|
||||||
|
# calculate elapsed time
|
||||||
|
elapsed_time = 'Unknown'
|
||||||
|
start_time = self.worker.start_time
|
||||||
|
end_time = self.worker.end_time
|
||||||
|
|
||||||
|
if start_time:
|
||||||
|
if end_time:
|
||||||
|
elapsed_time = str(end_time - start_time)
|
||||||
|
elif self.render_status() == RenderStatus.RUNNING:
|
||||||
|
elapsed_time = str(datetime.now() - start_time)
|
||||||
|
return elapsed_time
|
||||||
|
|
||||||
|
def frame_count(self):
|
||||||
|
return self.worker.total_frames
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def generate_id(cls):
|
def generate_id(cls):
|
||||||
return str(uuid.uuid4()).split('-')[0]
|
return str(uuid.uuid4()).split('-')[0]
|
||||||
@@ -334,11 +334,12 @@ class ScheduleJob(Frame):
|
|||||||
|
|
||||||
# multiple camera rendering
|
# multiple camera rendering
|
||||||
selected_cameras = self.blender_cameras_list.getCheckedItems() if self.blender_cameras_list else None
|
selected_cameras = self.blender_cameras_list.getCheckedItems() if self.blender_cameras_list else None
|
||||||
for cam in selected_cameras:
|
if selected_cameras:
|
||||||
job_copy = copy.deepcopy(job_json)
|
for cam in selected_cameras:
|
||||||
job_copy['args']['camera'] = cam.split('-')[0].strip()
|
job_copy = copy.deepcopy(job_json)
|
||||||
job_copy['name'] = pathlib.Path(input_path).stem.replace(' ', '_') + "-" + cam.replace(' ', '')
|
job_copy['args']['camera'] = cam.split('-')[0].strip()
|
||||||
job_list.append(job_copy)
|
job_copy['name'] = pathlib.Path(input_path).stem.replace(' ', '_') + "-" + cam.replace(' ', '')
|
||||||
|
job_list.append(job_copy)
|
||||||
|
|
||||||
# Submit to server
|
# Submit to server
|
||||||
job_list = job_list or [job_json]
|
job_list = job_list or [job_json]
|
||||||
|
|||||||
Reference in New Issue
Block a user