Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Harmony: fix clashing namespace of called js functions #584

Merged
merged 1 commit into from
Oct 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 22 additions & 15 deletions pype/hosts/harmony/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import sys
from uuid import uuid4

from avalon import api, io, harmony
from avalon.vendor import Qt
Expand All @@ -8,8 +9,11 @@
from pype import lib


signature = str(uuid4())


def set_scene_settings(settings):
func = """function func(args)
func = """function %s_func(args)
{
if (args[0]["fps"])
{
Expand All @@ -36,8 +40,8 @@ def set_scene_settings(settings):
)
}
}
func
"""
%s_func
""" % (signature, signature)
harmony.send({"function": func, "args": [settings]})


Expand Down Expand Up @@ -107,15 +111,15 @@ def check_inventory():
outdated_containers.append(container)

# Colour nodes.
func = """function func(args){
func = """function %s_func(args){
for( var i =0; i <= args[0].length - 1; ++i)
{
var red_color = new ColorRGBA(255, 0, 0, 255);
node.setColor(args[0][i], red_color);
}
}
func
"""
%s_func
""" % (signature, signature)
outdated_nodes = []
for container in outdated_containers:
if container["loader"] == "ImageSequenceLoader":
Expand Down Expand Up @@ -144,7 +148,7 @@ def application_launch():


def export_template(backdrops, nodes, filepath):
func = """function func(args)
func = """function %s_func(args)
{

var temp_node = node.add("Top", "temp_note", "NOTE", 0, 0, 0);
Expand Down Expand Up @@ -179,8 +183,8 @@ def export_template(backdrops, nodes, filepath):
Action.perform("onActionUpToParent()", "Node View");
node.deleteNode(template_group, true, true);
}
func
"""
%s_func
""" % (signature, signature)
harmony.send({
"function": func,
"args": [
Expand Down Expand Up @@ -221,12 +225,15 @@ def install():

def on_pyblish_instance_toggled(instance, old_value, new_value):
"""Toggle node enabling on instance toggles."""
func = """function func(args)
func = """function %s_func(args)
{
node.setEnable(args[0], args[1])
}
func
"""
harmony.send(
{"function": func, "args": [instance[0], new_value]}
)
%s_func
""" % (signature, signature)
try:
harmony.send(
{"function": func, "args": [instance[0], new_value]}
)
except IndexError:
print(f"Instance '{instance}' is missing node")