From 46c06ce20d8324aa70ec88ed8f898046a7d48b53 Mon Sep 17 00:00:00 2001 From: Toke Jepsen Date: Wed, 21 Aug 2019 16:09:31 +0100 Subject: [PATCH] Publish comments from NukeStudio. --- .../publish/integrate_ftrack_comments.py | 24 ++++++++++++++++ .../nukestudio/publish/collect_shots.py | 28 +++++++++++++++++-- 2 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 pype/plugins/ftrack/publish/integrate_ftrack_comments.py diff --git a/pype/plugins/ftrack/publish/integrate_ftrack_comments.py b/pype/plugins/ftrack/publish/integrate_ftrack_comments.py new file mode 100644 index 0000000000..889a78e254 --- /dev/null +++ b/pype/plugins/ftrack/publish/integrate_ftrack_comments.py @@ -0,0 +1,24 @@ +import pyblish.api + + +class IntegrateFtrackComments(pyblish.api.InstancePlugin): + """Create comments in Ftrack.""" + + order = pyblish.api.IntegratorOrder + label = "Integrate Comments to Ftrack." + families = ["shot"] + + def process(self, instance): + session = instance.context.data["ftrackSession"] + + entity = session.query( + "Shot where name is \"{}\"".format(instance.data["item"].name()) + ).one() + + notes = [] + for comment in instance.data["comments"]: + notes.append(session.create("Note", {"content": comment})) + + entity["notes"].extend(notes) + + session.commit() diff --git a/pype/plugins/nukestudio/publish/collect_shots.py b/pype/plugins/nukestudio/publish/collect_shots.py index 9fc14536fb..928dfd645b 100644 --- a/pype/plugins/nukestudio/publish/collect_shots.py +++ b/pype/plugins/nukestudio/publish/collect_shots.py @@ -30,6 +30,24 @@ class CollectShots(api.ContextPlugin): for key, value in instance.data.iteritems(): data[key] = value + # Collect comments. + data["comments"] = [] + + # Exclude non-tagged instances. + for tag in instance.data["tags"]: + if tag["name"].lower() == "comment": + data["comments"].append( + tag.metadata().dict()["tag.note"] + ) + + # Find tags on the source clip. + tags = instance.data["item"].source().tags() + for tag in tags: + if tag.name().lower() == "comment": + data["comments"].append( + tag.metadata().dict()["tag.note"] + ) + data["family"] = "shot" data["families"] = [] @@ -37,8 +55,14 @@ class CollectShots(api.ContextPlugin): data["name"] = data["subset"] + "_" + data["asset"] - data["label"] = data["asset"] + " - " + data["subset"] + " - tasks: {} - assetbuilds: {}".format( - data["tasks"], [x["name"] for x in data.get("assetbuilds", [])] + data["label"] = ( + "{} - {} - tasks:{} - assetbuilds:{} - comments:{}".format( + data["asset"], + data["subset"], + data["tasks"], + [x["name"] for x in data.get("assetbuilds", [])], + len(data["comments"]) + ) ) # Create instance.