mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
54 lines
1.7 KiB
Python
54 lines
1.7 KiB
Python
import pyblish.api
|
|
|
|
from openpype.pipeline.publish import get_errored_instances_from_context
|
|
from .lib import (
|
|
reset_selection,
|
|
select_nodes
|
|
)
|
|
|
|
|
|
class SelectInvalidAction(pyblish.api.Action):
|
|
"""Select invalid nodes in Nuke when plug-in failed.
|
|
|
|
To retrieve the invalid nodes this assumes a static `get_invalid()`
|
|
method is available on the plugin.
|
|
|
|
"""
|
|
label = "Select invalid nodes"
|
|
on = "failed" # This action is only available on a failed plug-in
|
|
icon = "search" # Icon from Awesome Icon
|
|
|
|
def process(self, context, plugin):
|
|
|
|
try:
|
|
import nuke
|
|
except ImportError:
|
|
raise ImportError("Current host is not Nuke")
|
|
|
|
errored_instances = get_errored_instances_from_context(context)
|
|
|
|
# Apply pyblish.logic to get the instances for the plug-in
|
|
instances = pyblish.api.instances_by_plugin(errored_instances, plugin)
|
|
|
|
# Get the invalid nodes for the plug-ins
|
|
self.log.info("Finding invalid nodes..")
|
|
invalid = list()
|
|
for instance in instances:
|
|
invalid_nodes = plugin.get_invalid(instance)
|
|
|
|
if invalid_nodes:
|
|
if isinstance(invalid_nodes, (list, tuple)):
|
|
invalid.append(invalid_nodes[0])
|
|
else:
|
|
self.log.warning("Plug-in returned to be invalid, "
|
|
"but has no selectable nodes.")
|
|
|
|
# Ensure unique (process each node only once)
|
|
invalid = list(set(invalid))
|
|
|
|
if invalid:
|
|
self.log.info("Selecting invalid nodes: {}".format(invalid))
|
|
reset_selection()
|
|
select_nodes(invalid)
|
|
else:
|
|
self.log.info("No invalid nodes found.")
|