mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
Merge branch '0002'
This commit is contained in:
commit
cda28a772b
11 changed files with 85 additions and 101 deletions
|
|
@ -20,6 +20,27 @@ def get_errored_instances_from_context(context):
|
|||
return instances
|
||||
|
||||
|
||||
def get_errored_plugins_from_data(context):
|
||||
"""Get all failed validation plugins
|
||||
|
||||
Args:
|
||||
context (object):
|
||||
|
||||
Returns:
|
||||
list of plugins which failed during validation
|
||||
|
||||
"""
|
||||
|
||||
plugins = list()
|
||||
results = context.data.get("results", [])
|
||||
for result in results:
|
||||
if result["success"] == True:
|
||||
continue
|
||||
plugins.append(result["plugin"])
|
||||
|
||||
return plugins
|
||||
|
||||
|
||||
class RepairAction(pyblish.api.Action):
|
||||
"""Repairs the action
|
||||
|
||||
|
|
@ -42,11 +63,35 @@ class RepairAction(pyblish.api.Action):
|
|||
|
||||
# Apply pyblish.logic to get the instances for the plug-in
|
||||
instances = pyblish.api.instances_by_plugin(errored_instances, plugin)
|
||||
|
||||
for instance in instances:
|
||||
plugin.repair(instance)
|
||||
|
||||
|
||||
class RepairContextAction(pyblish.api.Action):
|
||||
"""Repairs the action
|
||||
|
||||
To retrieve the invalid nodes this assumes a static `repair(instance)`
|
||||
method is available on the plugin.
|
||||
|
||||
"""
|
||||
label = "Repair Context"
|
||||
on = "failed" # This action is only available on a failed plug-in
|
||||
|
||||
def process(self, context, plugin):
|
||||
|
||||
if not hasattr(plugin, "repair"):
|
||||
raise RuntimeError("Plug-in does not have repair method.")
|
||||
|
||||
# Get the errored instances
|
||||
self.log.info("Finding failed instances..")
|
||||
errored_plugins = get_errored_plugins_from_data(context)
|
||||
|
||||
# Apply pyblish.logic to get the instances for the plug-in
|
||||
if plugin in errored_plugins:
|
||||
self.log.info("Attempting fix ...")
|
||||
plugin.repair()
|
||||
|
||||
|
||||
class SelectInvalidAction(pyblish.api.Action):
|
||||
"""Select invalid nodes in Maya when plug-in failed.
|
||||
|
||||
|
|
|
|||
|
|
@ -14,20 +14,10 @@ from .plugin import (
|
|||
from .action import (
|
||||
SelectInvalidAction,
|
||||
GenerateUUIDsOnInvalidAction,
|
||||
RepairAction
|
||||
RepairAction,
|
||||
RepairContextAction
|
||||
)
|
||||
|
||||
|
||||
def merge(*args):
|
||||
"""Helper to merge OrderedDict instances"""
|
||||
data = OrderedDict()
|
||||
for arg in args:
|
||||
for key, value in arg.items():
|
||||
data.pop(key, None)
|
||||
data[key] = value
|
||||
return data
|
||||
|
||||
|
||||
all = [
|
||||
"Extractor",
|
||||
"ValidatePipelineOrder",
|
||||
|
|
|
|||
|
|
@ -241,4 +241,4 @@ def collect_animation_data():
|
|||
|
||||
|
||||
def get_current_renderlayer():
|
||||
return cmds.editRenderLayerGlobals(query=True, currentRenderLayer=True)
|
||||
return cmds.editRenderLayerGlobals(query=True, currentRenderLayer=True)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
from maya import cmds
|
||||
|
||||
from avalon import api
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,20 +0,0 @@
|
|||
import pyblish.api
|
||||
import colorbleed.api
|
||||
|
||||
|
||||
class ValidateUnitsAngular(pyblish.api.ContextPlugin):
|
||||
"""Scene angular units must be in degrees"""
|
||||
|
||||
order = colorbleed.api.ValidateSceneOrder
|
||||
label = "Units (angular)"
|
||||
families = ["colorbleed.rig",
|
||||
"colorbleed.model",
|
||||
"colorbleed.pointcache",
|
||||
"colorbleed.curves"]
|
||||
|
||||
def process(self, context):
|
||||
units = context.data('angularUnits')
|
||||
|
||||
self.log.info('Units (angular): {0}'.format(units))
|
||||
assert units and units == 'deg', (
|
||||
"Scene angular units must be degrees")
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
import pyblish.api
|
||||
import colorbleed.api
|
||||
|
||||
|
||||
class ValidateUnitsFps(pyblish.api.ContextPlugin):
|
||||
"""Validate the scene linear, angular and time units."""
|
||||
|
||||
order = colorbleed.api.ValidateSceneOrder
|
||||
label = "Units (fps)"
|
||||
families = ["colorbleed.rig",
|
||||
"colorbleed.pointcache",
|
||||
"colorbleed.curves"]
|
||||
actions = [colorbleed.api.RepairAction]
|
||||
optional = True
|
||||
|
||||
def process(self, context):
|
||||
|
||||
fps = context.data['fps']
|
||||
|
||||
self.log.info('Units (time): {0} FPS'.format(fps))
|
||||
assert fps and fps == 25.0, "Scene must be 25 FPS"
|
||||
|
||||
@classmethod
|
||||
def repair(cls):
|
||||
"""Fix the current FPS setting of the scene, set to PAL(25.0 fps)
|
||||
"""
|
||||
import maya.cmds as cmds
|
||||
cmds.currentUnit(time="pal")
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
import pyblish.api
|
||||
import colorbleed.api
|
||||
|
||||
|
||||
class ValidateUnitsLinear(pyblish.api.ContextPlugin):
|
||||
"""Scene must be in linear units"""
|
||||
|
||||
order = colorbleed.api.ValidateSceneOrder
|
||||
label = "Units (linear)"
|
||||
families = ["colorbleed.rig",
|
||||
"colorbleed.model",
|
||||
"colorbleed.pointcache",
|
||||
"colorbleed.curves"]
|
||||
|
||||
def process(self, context):
|
||||
units = context.data('linearUnits')
|
||||
|
||||
self.log.info('Units (linear): {0}'.format(units))
|
||||
assert units and units == 'cm', ("Scene linear units must "
|
||||
"be centimeters")
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
import os
|
||||
|
||||
from maya import cmds
|
||||
|
||||
import pyblish.api
|
||||
|
|
|
|||
|
|
@ -81,7 +81,8 @@ class ValidateJointsHidden(pyblish.api.InstancePlugin):
|
|||
category = 'rig'
|
||||
version = (0, 1, 0)
|
||||
label = "Joints Hidden"
|
||||
actions = [colorbleed.api.SelectInvalidAction]
|
||||
actions = [colorbleed.api.SelectInvalidAction,
|
||||
colorbleed.api.RepairAction]
|
||||
|
||||
@staticmethod
|
||||
def get_invalid(instance):
|
||||
|
|
@ -93,5 +94,9 @@ class ValidateJointsHidden(pyblish.api.InstancePlugin):
|
|||
invalid = self.get_invalid(instance)
|
||||
|
||||
if invalid:
|
||||
raise ValueError("Visible joints found: "
|
||||
"{0}".format(invalid))
|
||||
raise ValueError("Visible joints found: {0}".format(invalid))
|
||||
|
||||
@classmethod
|
||||
def repair(cls, instance):
|
||||
import maya.mel as mel
|
||||
mel.eval("HideJoints")
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import maya.cmds as cmds
|
||||
|
||||
import pyblish.api
|
||||
import colorbleed.api
|
||||
|
||||
|
|
@ -11,7 +13,7 @@ class ValidateMayaUnits(pyblish.api.ContextPlugin):
|
|||
"colorbleed.model",
|
||||
"colorbleed.pointcache",
|
||||
"colorbleed.curves"]
|
||||
actions = [colorbleed.api.RepairAction]
|
||||
actions = [colorbleed.api.RepairContextAction]
|
||||
|
||||
def process(self, context):
|
||||
|
||||
|
|
@ -29,11 +31,23 @@ class ValidateMayaUnits(pyblish.api.ContextPlugin):
|
|||
|
||||
assert angularunits and angularunits == 'deg', ("Scene angular units "
|
||||
"must be degrees")
|
||||
|
||||
assert fps and fps == 25.0, "Scene must be 25 FP"
|
||||
assert fps and fps == 25.0, "Scene must be 25 FPS"
|
||||
|
||||
@classmethod
|
||||
def repair(cls):
|
||||
"""Fix the current FPS setting of the scene, set to PAL(25.0 fps)
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
"""Fix the current FPS setting of the scene, set to PAL(25.0 fps)"""
|
||||
|
||||
cls.log.info("Setting angular unit to 'degrees'")
|
||||
cmds.currentUnit(angle="degree")
|
||||
current_angle = cmds.currentUnit(query=True, angle=True)
|
||||
cls.log.debug(current_angle)
|
||||
|
||||
cls.log.info("Setting linear unit to 'centimeter'")
|
||||
cmds.currentUnit(linear="centimeter")
|
||||
current_linear = cmds.currentUnit(query=True, linear=True)
|
||||
cls.log.debug(current_linear)
|
||||
|
||||
cls.log.info("Setting time unit to 'PAL'")
|
||||
cmds.currentUnit(time="pal")
|
||||
current_time = cmds.currentUnit(query=True, time=True)
|
||||
cls.log.debug(current_time)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from maya import cmds
|
||||
|
||||
import pyblish.api
|
||||
import colorbleed.api
|
||||
|
||||
|
|
@ -19,17 +21,14 @@ class ValidateRigContents(pyblish.api.InstancePlugin):
|
|||
|
||||
def process(self, instance):
|
||||
|
||||
from maya import cmds
|
||||
|
||||
objsets = ("controls_SET", "out_SET")
|
||||
objectsets = ("controls_SET", "out_SET")
|
||||
|
||||
missing = list()
|
||||
for objset in objsets:
|
||||
if objset not in instance:
|
||||
missing.append(objset)
|
||||
for objectset in objectsets:
|
||||
if objectset not in instance:
|
||||
missing.append(objectset)
|
||||
|
||||
assert not missing, ("%s is missing %s"
|
||||
% (instance, missing))
|
||||
assert not missing, ("%s is missing %s" % (instance, missing))
|
||||
|
||||
# Ensure there are at least some transforms or dag nodes
|
||||
# in the rig instance
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue