Flamenco: Write more extensive information to jobinfo.json

This introduces version 2 of that file.

Version 1:
    - Only the job doc was saved, with 'missing_files' added inside it.

Version 2:
  - '_meta' key was added to indicate version.
  - 'job' is saved in a 'job' key, 'misssing_files' still top-level key.
  - 'exclusion_filter', 'project_settings', and
    'flamenco_manager_settings' keys were added.
This commit is contained in:
Sybren A. Stüvel 2018-12-05 12:57:39 +01:00
parent 419249ee19
commit ef57dba5d3
2 changed files with 36 additions and 4 deletions

View File

@ -45,7 +45,7 @@ import bpy
from bpy.types import AddonPreferences, Operator, WindowManager, Scene, PropertyGroup from bpy.types import AddonPreferences, Operator, WindowManager, Scene, PropertyGroup
from bpy.props import StringProperty, EnumProperty, PointerProperty, BoolProperty, IntProperty from bpy.props import StringProperty, EnumProperty, PointerProperty, BoolProperty, IntProperty
from .. import async_loop, pillar, project_specific from .. import async_loop, pillar, project_specific, utils
from ..utils import pyside_cache, redraw from ..utils import pyside_cache, redraw
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -284,9 +284,10 @@ class FLAMENCO_OT_render(async_loop.AsyncModalOperatorMixin,
# requires a specific file format. # requires a specific file format.
settings.setdefault('format', scene.render.image_settings.file_format) settings.setdefault('format', scene.render.image_settings.file_format)
project_id = prefs.project.project
try: try:
job_info = await create_job(self.user_id, job_info = await create_job(self.user_id,
prefs.project.project, project_id,
manager_id, manager_id,
scene.flamenco_render_job_type, scene.flamenco_render_job_type,
settings, settings,
@ -302,8 +303,29 @@ class FLAMENCO_OT_render(async_loop.AsyncModalOperatorMixin,
with open(str(outdir / 'jobinfo.json'), 'w', encoding='utf8') as outfile: with open(str(outdir / 'jobinfo.json'), 'w', encoding='utf8') as outfile:
import json import json
job_info['missing_files'] = [str(mf) for mf in missing_sources] # Version 1: Only the job doc was saved, with 'missing_files' added inside it.
json.dump(job_info, outfile, sort_keys=True, indent=4) # Version 2:
# - '_meta' key was added to indicate version.
# - 'job' is saved in a 'job' key, 'misssing_files' still top-level key.
# - 'exclusion_filter', 'project_settings', and 'flamenco_manager_settings'
# keys were added.
project_settings = prefs.get('project_settings', {}).get(project_id, {})
if hasattr(project_settings, 'to_dict'):
project_settings = project_settings.to_dict()
# Pop out some settings so that settings of irrelevant Managers are excluded.
flamenco_managers_settings = project_settings.pop('flamenco_managers_settings', {})
flamenco_manager_settings = flamenco_managers_settings.pop(manager_id)
info = {
'_meta': {'version': 2},
'job': job_info,
'missing_files': [str(mf) for mf in missing_sources],
'exclusion_filter': (prefs.flamenco_exclude_filter or '').strip(),
'project_settings': project_settings,
'flamenco_manager_settings': flamenco_manager_settings,
}
json.dump(info, outfile, sort_keys=True, indent=4, cls=utils.JSONEncoder)
# We can now remove the local copy we made with bpy.ops.wm.save_as_mainfile(). # We can now remove the local copy we made with bpy.ops.wm.save_as_mainfile().
# Strictly speaking we can already remove it after the BAT-pack, but it may come in # Strictly speaking we can already remove it after the BAT-pack, but it may come in

View File

@ -16,6 +16,7 @@
# #
# ##### END GPL LICENSE BLOCK ##### # ##### END GPL LICENSE BLOCK #####
import json
import pathlib import pathlib
@ -102,3 +103,12 @@ def redraw(self, context):
if context.area is None: if context.area is None:
return return
context.area.tag_redraw() context.area.tag_redraw()
class JSONEncoder(json.JSONEncoder):
"""JSON encoder with support for some Blender types."""
def default(self, o):
if o.__class__.__name__ == 'IDPropertyGroup' and hasattr(o, 'to_dict'):
return o.to_dict()
return super().default(o)