raise PublishXmlValidationError in validate scene settings

This commit is contained in:
iLLiCiTiT 2021-12-22 13:02:32 +01:00
parent db5d03c902
commit 6b6961a84a
2 changed files with 50 additions and 8 deletions

View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<error id="main">
<title>Scene settings</title>
<description>## Invalid scene settings
Scene settings do not match to expected values.
**FPS**
- Expected value: {expected_fps}
- Current value: {current_fps}
**Resolution**
- Expected value: {expected_width}x{expected_height}
- Current value: {current_width}x{current_height}
**Pixel ratio**
- Expected value: {expected_pixel_ratio}
- Current value: {current_pixel_ratio}
### How to repair?
FPS and Pixel ratio can be modified in scene setting. Wrong resolution can be fixed with changing resolution of scene but due to TVPaint limitations it is possible that you will need to create new scene.
</description>
</error>
</root>

View file

@ -1,9 +1,11 @@
import json
import pyblish.api
from openpype.pipeline import PublishXmlValidationError
class ValidateSceneSettings(pyblish.api.ContextPlugin):
# TODO @iLliCiTiT add fix action for fps
class ValidateProjectSettings(pyblish.api.ContextPlugin):
"""Validate scene settings against database."""
label = "Validate Scene Settings"
@ -11,6 +13,7 @@ class ValidateSceneSettings(pyblish.api.ContextPlugin):
optional = True
def process(self, context):
expected_data = context.data["assetEntity"]["data"]
scene_data = {
"fps": context.data.get("sceneFps"),
"resolutionWidth": context.data.get("sceneWidth"),
@ -19,15 +22,28 @@ class ValidateSceneSettings(pyblish.api.ContextPlugin):
}
invalid = {}
for k in scene_data.keys():
expected_value = context.data["assetEntity"]["data"][k]
expected_value = expected_data[k]
if scene_data[k] != expected_value:
invalid[k] = {
"current": scene_data[k], "expected": expected_value
}
if invalid:
raise AssertionError(
"Scene settings does not match database:\n{}".format(
json.dumps(invalid, sort_keys=True, indent=4)
)
)
if not invalid:
return
raise PublishXmlValidationError(
self,
"Scene settings does not match database:\n{}".format(
json.dumps(invalid, sort_keys=True, indent=4)
),
formatting_data={
"expected_fps": expected_data["fps"],
"current_fps": scene_data["fps"],
"expected_width": expected_data["resolutionWidth"],
"expected_height": expected_data["resolutionHeight"],
"current_width": scene_data["resolutionWidth"],
"current_height": scene_data["resolutionWidth"],
"expected_pixel_ratio": expected_data["pixelAspect"],
"current_pixel_ratio": scene_data["pixelAspect"]
}
)