mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Merge remote-tracking branch 'origin/master' into feature/harmony-tweaks
This commit is contained in:
commit
5e575043ff
13 changed files with 95 additions and 78 deletions
|
|
@ -1,6 +1,5 @@
|
|||
import os
|
||||
import sys
|
||||
from uuid import uuid4
|
||||
|
||||
from avalon import api, io, harmony
|
||||
from avalon.vendor import Qt
|
||||
|
|
@ -10,11 +9,10 @@ from pype import lib
|
|||
from pype.api import config
|
||||
|
||||
|
||||
signature = str(uuid4())
|
||||
|
||||
|
||||
def set_scene_settings(settings):
|
||||
func = """function %s_func(args)
|
||||
|
||||
signature = harmony.signature("set_scene_settings")
|
||||
func = """function %s(args)
|
||||
{
|
||||
if (args[0]["fps"])
|
||||
{
|
||||
|
|
@ -41,7 +39,7 @@ def set_scene_settings(settings):
|
|||
)
|
||||
}
|
||||
}
|
||||
%s_func
|
||||
%s
|
||||
""" % (signature, signature)
|
||||
harmony.send({"function": func, "args": [settings]})
|
||||
|
||||
|
|
@ -62,9 +60,12 @@ def get_asset_settings():
|
|||
"resolutionHeight": resolution_height
|
||||
}
|
||||
|
||||
harmony_config = config.get_presets().["harmony"]["general"]
|
||||
try:
|
||||
skip_resolution_check = \
|
||||
config.get_presets()["harmony"]["general"]["skip_resolution_check"]
|
||||
except KeyError:
|
||||
skip_resolution_check = []
|
||||
|
||||
skip_resolution_check = harmony_config.get(["skip_resolution_check"], [])
|
||||
if os.getenv('AVALON_TASK') in skip_resolution_check:
|
||||
scene_data.pop("resolutionWidth")
|
||||
scene_data.pop("resolutionHeight")
|
||||
|
|
@ -84,21 +85,20 @@ def ensure_scene_settings():
|
|||
valid_settings[key] = value
|
||||
|
||||
# Warn about missing attributes.
|
||||
print("Starting new QApplication..")
|
||||
app = Qt.QtWidgets.QApplication(sys.argv)
|
||||
|
||||
message_box = Qt.QtWidgets.QMessageBox()
|
||||
message_box.setIcon(Qt.QtWidgets.QMessageBox.Warning)
|
||||
msg = "Missing attributes:"
|
||||
if invalid_settings:
|
||||
print("Starting new QApplication..")
|
||||
app = Qt.QtWidgets.QApplication.instance()
|
||||
if not app:
|
||||
app = Qt.QtWidgets.QApplication(sys.argv)
|
||||
|
||||
message_box = Qt.QtWidgets.QMessageBox()
|
||||
message_box.setIcon(Qt.QtWidgets.QMessageBox.Warning)
|
||||
msg = "Missing attributes:"
|
||||
for item in invalid_settings:
|
||||
msg += f"\n{item}"
|
||||
message_box.setText(msg)
|
||||
message_box.exec_()
|
||||
|
||||
# Garbage collect QApplication.
|
||||
del app
|
||||
|
||||
set_scene_settings(valid_settings)
|
||||
|
||||
|
||||
|
|
@ -121,15 +121,17 @@ def check_inventory():
|
|||
outdated_containers.append(container)
|
||||
|
||||
# Colour nodes.
|
||||
func = """function %s_func(args){
|
||||
sig = harmony.signature("set_color")
|
||||
func = """function %s(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);
|
||||
}
|
||||
}
|
||||
%s_func
|
||||
""" % (signature, signature)
|
||||
%s
|
||||
""" % (sig, sig)
|
||||
outdated_nodes = []
|
||||
for container in outdated_containers:
|
||||
if container["loader"] == "ImageSequenceLoader":
|
||||
|
|
@ -158,7 +160,9 @@ def application_launch():
|
|||
|
||||
|
||||
def export_template(backdrops, nodes, filepath):
|
||||
func = """function %s_func(args)
|
||||
|
||||
sig = harmony.signature("set_color")
|
||||
func = """function %s(args)
|
||||
{
|
||||
|
||||
var temp_node = node.add("Top", "temp_note", "NOTE", 0, 0, 0);
|
||||
|
|
@ -193,8 +197,8 @@ def export_template(backdrops, nodes, filepath):
|
|||
Action.perform("onActionUpToParent()", "Node View");
|
||||
node.deleteNode(template_group, true, true);
|
||||
}
|
||||
%s_func
|
||||
""" % (signature, signature)
|
||||
%s
|
||||
""" % (sig, sig)
|
||||
harmony.send({
|
||||
"function": func,
|
||||
"args": [
|
||||
|
|
@ -235,12 +239,14 @@ def install():
|
|||
|
||||
def on_pyblish_instance_toggled(instance, old_value, new_value):
|
||||
"""Toggle node enabling on instance toggles."""
|
||||
func = """function %s_func(args)
|
||||
|
||||
sig = harmony.signature("enable_node")
|
||||
func = """function %s(args)
|
||||
{
|
||||
node.setEnable(args[0], args[1])
|
||||
}
|
||||
%s_func
|
||||
""" % (signature, signature)
|
||||
%s
|
||||
""" % (sig, sig)
|
||||
try:
|
||||
harmony.send(
|
||||
{"function": func, "args": [instance[0], new_value]}
|
||||
|
|
|
|||
|
|
@ -13,13 +13,14 @@ class CreateRender(harmony.Creator):
|
|||
super(CreateRender, self).__init__(*args, **kwargs)
|
||||
|
||||
def setup_node(self, node):
|
||||
func = """function func(args)
|
||||
sig = harmony.signature()
|
||||
func = """function %s(args)
|
||||
{
|
||||
node.setTextAttr(args[0], "DRAWING_TYPE", 1, "PNG4");
|
||||
node.setTextAttr(args[0], "DRAWING_NAME", 1, args[1]);
|
||||
node.setTextAttr(args[0], "MOVIE_PATH", 1, args[1]);
|
||||
}
|
||||
func
|
||||
"""
|
||||
%s
|
||||
""" % (sig, sig)
|
||||
path = "{0}/{0}".format(node.split("/")[-1])
|
||||
harmony.send({"function": func, "args": [node, path]})
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from avalon import api, harmony
|
||||
|
||||
|
||||
sig = harmony.signature()
|
||||
func = """
|
||||
function getUniqueColumnName( column_prefix )
|
||||
{
|
||||
|
|
@ -18,14 +18,14 @@ function getUniqueColumnName( column_prefix )
|
|||
return column_name;
|
||||
}
|
||||
|
||||
function func(args)
|
||||
function %s(args)
|
||||
{
|
||||
var uniqueColumnName = getUniqueColumnName(args[0]);
|
||||
column.add(uniqueColumnName , "SOUND");
|
||||
column.importSound(uniqueColumnName, 1, args[1]);
|
||||
}
|
||||
func
|
||||
"""
|
||||
%s
|
||||
""" % (sig, sig)
|
||||
|
||||
|
||||
class ImportAudioLoader(api.Loader):
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
import os
|
||||
import uuid
|
||||
|
||||
import clique
|
||||
import json
|
||||
|
||||
from avalon import api, harmony
|
||||
import pype.lib
|
||||
import json
|
||||
|
||||
|
||||
copy_files = """function copyFile(srcFilename, dstFilename)
|
||||
{
|
||||
|
|
@ -256,7 +254,9 @@ class BackgroundLoader(api.Loader):
|
|||
container_nodes = []
|
||||
|
||||
for layer in sorted(layers):
|
||||
file_to_import = [os.path.join(bg_folder, layer).replace("\\", "/")]
|
||||
file_to_import = [
|
||||
os.path.join(bg_folder, layer).replace("\\", "/")
|
||||
]
|
||||
|
||||
read_node = harmony.send(
|
||||
{
|
||||
|
|
@ -301,8 +301,10 @@ class BackgroundLoader(api.Loader):
|
|||
print(container)
|
||||
|
||||
for layer in sorted(layers):
|
||||
file_to_import = [os.path.join(bg_folder, layer).replace("\\", "/")]
|
||||
print(20*"#")
|
||||
file_to_import = [
|
||||
os.path.join(bg_folder, layer).replace("\\", "/")
|
||||
]
|
||||
print(20 * "#")
|
||||
print(f"FILE TO REPLACE: {file_to_import}")
|
||||
print(f"LAYER: {layer}")
|
||||
node = harmony.find_node_by_name(layer, "READ")
|
||||
|
|
@ -324,9 +326,9 @@ class BackgroundLoader(api.Loader):
|
|||
)["result"]
|
||||
container['nodes'].append(read_node)
|
||||
|
||||
|
||||
# Colour node.
|
||||
func = """function func(args){
|
||||
sig = harmony.signature("set_color")
|
||||
func = """function %s(args){
|
||||
for( var i =0; i <= args[0].length - 1; ++i)
|
||||
{
|
||||
var red_color = new ColorRGBA(255, 0, 0, 255);
|
||||
|
|
@ -339,8 +341,8 @@ class BackgroundLoader(api.Loader):
|
|||
}
|
||||
}
|
||||
}
|
||||
func
|
||||
"""
|
||||
%s
|
||||
""" % (sig, sig)
|
||||
if pype.lib.is_latest(representation):
|
||||
harmony.send({"function": func, "args": [node, "green"]})
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -301,7 +301,8 @@ class ImageSequenceLoader(api.Loader):
|
|||
)
|
||||
|
||||
# Colour node.
|
||||
func = """function func(args){
|
||||
sig = harmony.signature("copyFile")
|
||||
func = """function %s(args){
|
||||
for( var i =0; i <= args[0].length - 1; ++i)
|
||||
{
|
||||
var red_color = new ColorRGBA(255, 0, 0, 255);
|
||||
|
|
@ -314,8 +315,8 @@ class ImageSequenceLoader(api.Loader):
|
|||
}
|
||||
}
|
||||
}
|
||||
func
|
||||
"""
|
||||
%s
|
||||
""" % (sig, sig)
|
||||
if pype.lib.is_latest(representation):
|
||||
harmony.send({"function": func, "args": [node, "green"]})
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -21,15 +21,16 @@ class ImportTemplateLoader(api.Loader):
|
|||
with zipfile.ZipFile(zip_file, "r") as zip_ref:
|
||||
zip_ref.extractall(template_path)
|
||||
|
||||
func = """function func(args)
|
||||
sig = harmony.signature("paste")
|
||||
func = """function %s(args)
|
||||
{
|
||||
var template_path = args[0];
|
||||
var drag_object = copyPaste.pasteTemplateIntoGroup(
|
||||
template_path, "Top", 1
|
||||
);
|
||||
}
|
||||
func
|
||||
"""
|
||||
%s
|
||||
""" % (sig, sig)
|
||||
|
||||
harmony.send({"function": func, "args": [template_path]})
|
||||
|
||||
|
|
|
|||
|
|
@ -13,15 +13,16 @@ class CollectCurrentFile(pyblish.api.ContextPlugin):
|
|||
|
||||
def process(self, context):
|
||||
"""Inject the current working file"""
|
||||
func = """function func()
|
||||
sig = harmony.signature()
|
||||
func = """function %s()
|
||||
{
|
||||
return (
|
||||
scene.currentProjectPath() + "/" +
|
||||
scene.currentVersionName() + ".xstage"
|
||||
);
|
||||
}
|
||||
func
|
||||
"""
|
||||
%s
|
||||
""" % (sig, sig)
|
||||
|
||||
current_file = harmony.send({"function": func})["result"]
|
||||
context.data["currentFile"] = os.path.normpath(current_file)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@ class CollectPalettes(pyblish.api.ContextPlugin):
|
|||
hosts = ["harmony"]
|
||||
|
||||
def process(self, context):
|
||||
func = """function func()
|
||||
sig = harmony.signature()
|
||||
func = """function %s()
|
||||
{
|
||||
var palette_list = PaletteObjectManager.getScenePaletteList();
|
||||
|
||||
|
|
@ -26,8 +27,8 @@ class CollectPalettes(pyblish.api.ContextPlugin):
|
|||
|
||||
return palettes;
|
||||
}
|
||||
func
|
||||
"""
|
||||
%s
|
||||
""" % (sig, sig)
|
||||
palettes = harmony.send({"function": func})["result"]
|
||||
|
||||
for name, id in palettes.items():
|
||||
|
|
|
|||
|
|
@ -13,14 +13,15 @@ class ExtractPalette(pype.api.Extractor):
|
|||
families = ["harmony.palette"]
|
||||
|
||||
def process(self, instance):
|
||||
func = """function func(args)
|
||||
sig = harmony.signature()
|
||||
func = """function %s(args)
|
||||
{
|
||||
var palette_list = PaletteObjectManager.getScenePaletteList();
|
||||
var palette = palette_list.getPaletteById(args[0]);
|
||||
return (palette.getPath() + "/" + palette.getName() + ".plt");
|
||||
}
|
||||
func
|
||||
"""
|
||||
%s
|
||||
""" % (sig, sig)
|
||||
palette_file = harmony.send(
|
||||
{"function": func, "args": [instance.data["id"]]}
|
||||
)["result"]
|
||||
|
|
|
|||
|
|
@ -130,6 +130,9 @@ class ExtractRender(pyblish.api.InstancePlugin):
|
|||
}
|
||||
instance.data["representations"] = [representation, thumbnail]
|
||||
|
||||
if audio_path and os.path.exists(audio_path):
|
||||
instance.data["audio"] = [{"filename": audio_path}]
|
||||
|
||||
# Required for extract_review plugin (L222 onwards).
|
||||
instance.data["frameStart"] = frame_start
|
||||
instance.data["frameEnd"] = frame_end
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import os
|
|||
import shutil
|
||||
|
||||
import pype.api
|
||||
import avalon.harmony
|
||||
from avalon import harmony
|
||||
import pype.hosts.harmony
|
||||
|
||||
|
||||
|
|
@ -15,9 +15,9 @@ class ExtractTemplate(pype.api.Extractor):
|
|||
|
||||
def process(self, instance):
|
||||
staging_dir = self.staging_dir(instance)
|
||||
filepath = os.path.join(staging_dir, "{}.tpl".format(instance.name))
|
||||
filepath = os.path.join(staging_dir, f"{instance.name}.tpl")
|
||||
|
||||
self.log.info("Outputting template to {}".format(staging_dir))
|
||||
self.log.info(f"Outputting template to {staging_dir}")
|
||||
|
||||
dependencies = []
|
||||
self.get_dependencies(instance[0], dependencies)
|
||||
|
|
@ -50,21 +50,22 @@ class ExtractTemplate(pype.api.Extractor):
|
|||
# Prep representation.
|
||||
os.chdir(staging_dir)
|
||||
shutil.make_archive(
|
||||
"{}".format(instance.name),
|
||||
f"{instance.name}",
|
||||
"zip",
|
||||
os.path.join(staging_dir, "{}.tpl".format(instance.name))
|
||||
os.path.join(staging_dir, f"{instance.name}.tpl")
|
||||
)
|
||||
|
||||
representation = {
|
||||
"name": "tpl",
|
||||
"ext": "zip",
|
||||
"files": "{}.zip".format(instance.name),
|
||||
"files": f"{instance.name}.zip",
|
||||
"stagingDir": staging_dir
|
||||
}
|
||||
instance.data["representations"] = [representation]
|
||||
|
||||
def get_backdrops(self, node):
|
||||
func = """function func(probe_node)
|
||||
sig = harmony.signature()
|
||||
func = """function %s(probe_node)
|
||||
{
|
||||
var backdrops = Backdrop.backdrops("Top");
|
||||
var valid_backdrops = [];
|
||||
|
|
@ -90,14 +91,15 @@ class ExtractTemplate(pype.api.Extractor):
|
|||
}
|
||||
return valid_backdrops;
|
||||
}
|
||||
func
|
||||
"""
|
||||
return avalon.harmony.send(
|
||||
%s
|
||||
""" % (sig, sig)
|
||||
return harmony.send(
|
||||
{"function": func, "args": [node]}
|
||||
)["result"]
|
||||
|
||||
def get_dependencies(self, node, dependencies):
|
||||
func = """function func(args)
|
||||
sig = harmony.signature()
|
||||
func = """function %s(args)
|
||||
{
|
||||
var target_node = args[0];
|
||||
var numInput = node.numberOfInputPorts(target_node);
|
||||
|
|
@ -108,10 +110,10 @@ class ExtractTemplate(pype.api.Extractor):
|
|||
}
|
||||
return dependencies;
|
||||
}
|
||||
func
|
||||
"""
|
||||
%s
|
||||
""" % (sig, sig)
|
||||
|
||||
current_dependencies = avalon.harmony.send(
|
||||
current_dependencies = harmony.send(
|
||||
{"function": func, "args": [node]}
|
||||
)["result"]
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class ExtractWorkfile(pype.api.Extractor):
|
|||
os.path.join(staging_dir, f"{instance.name}.tpl")
|
||||
)
|
||||
# Check if archive is ok
|
||||
with ZipFile(os.path.basename("f{instance.name}.zip")) as zr:
|
||||
with ZipFile(os.path.basename(f"{instance.name}.zip")) as zr:
|
||||
if zr.testzip() is not None:
|
||||
raise Exception("File archive is corrupted.")
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
import json
|
||||
import os
|
||||
|
||||
import pyblish.api
|
||||
|
||||
import avalon.harmony
|
||||
import pype.hosts.harmony
|
||||
from avalon import harmony
|
||||
|
||||
|
||||
class ValidateAudio(pyblish.api.InstancePlugin):
|
||||
|
|
@ -30,7 +28,7 @@ class ValidateAudio(pyblish.api.InstancePlugin):
|
|||
}
|
||||
func
|
||||
"""
|
||||
result = avalon.harmony.send(
|
||||
result = harmony.send(
|
||||
{"function": func, "args": [instance[0]]}
|
||||
)["result"]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue