OP-2765 - added methods for New Publisher

Removed uuid, replaced with instance_id or first members item
This commit is contained in:
Petr Kalis 2022-03-03 15:21:42 +01:00
parent 7b1821238d
commit 7f83c8a2d0
3 changed files with 45 additions and 22 deletions

View file

@ -16,7 +16,10 @@ from .pipeline import (
uninstall, uninstall,
list_instances, list_instances,
remove_instance, remove_instance,
containerise containerise,
get_context_data,
update_context_data,
get_context_title
) )
from .workio import ( from .workio import (
@ -51,6 +54,9 @@ __all__ = [
"list_instances", "list_instances",
"remove_instance", "remove_instance",
"containerise", "containerise",
"get_context_data",
"update_context_data",
"get_context_title",
"file_extensions", "file_extensions",
"has_unsaved_changes", "has_unsaved_changes",

View file

@ -10,6 +10,7 @@ from avalon import io, pipeline
from openpype import lib from openpype import lib
from openpype.api import Logger from openpype.api import Logger
import openpype.hosts.aftereffects import openpype.hosts.aftereffects
from openpype.pipeline import BaseCreator
from .launch_logic import get_stub from .launch_logic import get_stub
@ -67,6 +68,7 @@ def install():
avalon.api.register_plugin_path(avalon.api.Loader, LOAD_PATH) avalon.api.register_plugin_path(avalon.api.Loader, LOAD_PATH)
avalon.api.register_plugin_path(avalon.api.Creator, CREATE_PATH) avalon.api.register_plugin_path(avalon.api.Creator, CREATE_PATH)
avalon.api.register_plugin_path(BaseCreator, CREATE_PATH)
log.info(PUBLISH_PATH) log.info(PUBLISH_PATH)
pyblish.api.register_callback( pyblish.api.register_callback(
@ -238,12 +240,6 @@ def list_instances():
if instance.get("schema") and \ if instance.get("schema") and \
"container" in instance.get("schema"): "container" in instance.get("schema"):
continue continue
uuid_val = instance.get("uuid")
if uuid_val:
instance['uuid'] = uuid_val
else:
instance['uuid'] = instance.get("members")[0] # legacy
instances.append(instance) instances.append(instance)
return instances return instances
@ -265,8 +261,29 @@ def remove_instance(instance):
if not stub: if not stub:
return return
stub.remove_instance(instance.get("uuid")) inst_id = instance.get("instance_id")
item = stub.get_item(instance.get("uuid")) if not inst_id:
log.warning("No instance identifier for {}".format(instance))
return
stub.remove_instance(inst_id)
if instance.members:
item = stub.get_item(instance.members[0])
if item: if item:
stub.rename_item(item.id, stub.rename_item(item.id,
item.name.replace(stub.PUBLISH_ICON, '')) item.name.replace(stub.PUBLISH_ICON, ''))
def get_context_data():
print("get_context_data")
return {}
def update_context_data(data, changes):
print("update_context_data")
def get_context_title():
"""Returns title for Creator window"""
return "AfterEffects"

View file

@ -28,6 +28,7 @@ class AEItem(object):
workAreaDuration = attr.ib(default=None) workAreaDuration = attr.ib(default=None)
frameRate = attr.ib(default=None) frameRate = attr.ib(default=None)
file_name = attr.ib(default=None) file_name = attr.ib(default=None)
instance_id = attr.ib(default=None) # New Publisher
class AfterEffectsServerStub(): class AfterEffectsServerStub():
@ -132,8 +133,9 @@ class AfterEffectsServerStub():
is_new = True is_new = True
for item_meta in items_meta: for item_meta in items_meta:
if item_meta.get('members') \ if ((item_meta.get('members') and
and str(item.id) == str(item_meta.get('members')[0]): str(item.id) == str(item_meta.get('members')[0])) or
item_meta.get("instance_id") == item.id):
is_new = False is_new = False
if data: if data:
item_meta.update(data) item_meta.update(data)
@ -314,15 +316,12 @@ class AfterEffectsServerStub():
Keep matching item in file though. Keep matching item in file though.
Args: Args:
instance_id(string): instance uuid instance_id(string): instance id
""" """
cleaned_data = [] cleaned_data = []
for instance in self.get_metadata(): for instance in self.get_metadata():
uuid_val = instance.get("uuid") if instance.get("instance_id") != instance_id:
if not uuid_val:
uuid_val = instance.get("members")[0] # legacy
if uuid_val != instance_id:
cleaned_data.append(instance) cleaned_data.append(instance)
payload = json.dumps(cleaned_data, indent=4) payload = json.dumps(cleaned_data, indent=4)
@ -357,7 +356,7 @@ class AfterEffectsServerStub():
item_id (int): item_id (int):
Returns: Returns:
(namedtuple) (AEItem)
""" """
res = self.websocketserver.call(self.client.call res = self.websocketserver.call(self.client.call
@ -418,7 +417,7 @@ class AfterEffectsServerStub():
""" Get render queue info for render purposes """ Get render queue info for render purposes
Returns: Returns:
(namedtuple): with 'file_name' field (AEItem): with 'file_name' field
""" """
res = self.websocketserver.call(self.client.call res = self.websocketserver.call(self.client.call
('AfterEffects.get_render_info')) ('AfterEffects.get_render_info'))
@ -606,7 +605,8 @@ class AfterEffectsServerStub():
d.get('workAreaStart'), d.get('workAreaStart'),
d.get('workAreaDuration'), d.get('workAreaDuration'),
d.get('frameRate'), d.get('frameRate'),
d.get('file_name')) d.get('file_name'),
d.get("instance_id"))
ret.append(item) ret.append(item)
return ret return ret