From c7b78dad5be6930cd5e338bcd16d186434d340a2 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Fri, 29 Jan 2021 19:07:47 +0100 Subject: [PATCH] resolve: fix testing utils import modules --- pype/hosts/resolve/api/testing_utils.py | 94 +++++++++---------- .../utility_scripts/tests/test_otio_as_xml.py | 47 ++++++++++ 2 files changed, 93 insertions(+), 48 deletions(-) create mode 100644 pype/hosts/resolve/utility_scripts/tests/test_otio_as_xml.py diff --git a/pype/hosts/resolve/api/testing_utils.py b/pype/hosts/resolve/api/testing_utils.py index b30fc7c24e..98ad6abcf1 100644 --- a/pype/hosts/resolve/api/testing_utils.py +++ b/pype/hosts/resolve/api/testing_utils.py @@ -1,56 +1,54 @@ #! python3 -import os class TestGUI: - resolve = bmd.scriptapp("Resolve") # noqa - fu = resolve.Fusion() - ui = fu.UIManager - disp = bmd.UIDispatcher(fu.UIManager) # noqa - title_font = ui.Font({"PixelSize": 18}) - _dialogue = disp.AddWindow( - { - "WindowTitle": "Get Testing folder", - "ID": "TestingWin", - "Geometry": [250, 250, 250, 100], - "Spacing": 0, - "Margin": 10 - }, - [ - ui.VGroup( - { - "Spacing": 2 - }, - [ - ui.Button( - { - "ID": "inputTestSourcesFolder", - "Text": "Select folder with testing medias", - "Weight": 1.25, - "ToolTip": ( - "Chose folder with videos, sequences, " - "single images, nested folders with " - "medias" - ), - "Flat": False - } - ), - ui.VGap(), - ui.Button( - { - "ID": "openButton", - "Text": "Process Test", - "Weight": 2, - "ToolTip": "Run the test...", - "Flat": False - } - ) - ] - ) - ] - ) - def __init__(self): + resolve = bmd.scriptapp("Resolve") # noqa + self.fu = resolve.Fusion() + ui = self.fu.UIManager + self.disp = bmd.UIDispatcher(self.fu.UIManager) # noqa + self.title_font = ui.Font({"PixelSize": 18}) + self._dialogue = self.disp.AddWindow( + { + "WindowTitle": "Get Testing folder", + "ID": "TestingWin", + "Geometry": [250, 250, 250, 100], + "Spacing": 0, + "Margin": 10 + }, + [ + ui.VGroup( + { + "Spacing": 2 + }, + [ + ui.Button( + { + "ID": "inputTestSourcesFolder", + "Text": "Select folder with testing medias", + "Weight": 1.25, + "ToolTip": ( + "Chose folder with videos, sequences, " + "single images, nested folders with " + "medias" + ), + "Flat": False + } + ), + ui.VGap(), + ui.Button( + { + "ID": "openButton", + "Text": "Process Test", + "Weight": 2, + "ToolTip": "Run the test...", + "Flat": False + } + ) + ] + ) + ] + ) self._widgets = self._dialogue.GetItems() self._dialogue.On.TestingWin.Close = self._close_window self._dialogue.On.inputTestSourcesFolder.Clicked = self._open_dir_button_pressed # noqa diff --git a/pype/hosts/resolve/utility_scripts/tests/test_otio_as_xml.py b/pype/hosts/resolve/utility_scripts/tests/test_otio_as_xml.py new file mode 100644 index 0000000000..1fe0451003 --- /dev/null +++ b/pype/hosts/resolve/utility_scripts/tests/test_otio_as_xml.py @@ -0,0 +1,47 @@ +#! python3 +import os +import sys +import avalon.api as avalon +import pype +import opentimelineio as otio +from opentimelineio_contrib import adapters as otio_adapters +from pype.hosts.resolve import TestGUI +import pype.hosts.resolve as bmdvr +from pype.hosts.resolve.otio import davinci_export as otio_export + + +class ThisTestGUI(TestGUI): + extensions = [".exr", ".jpg", ".mov", ".png", ".mp4", ".ari", ".arx"] + + def __init__(self): + super(ThisTestGUI, self).__init__() + # Registers pype's Global pyblish plugins + pype.install() + # activate resolve from pype + avalon.install(bmdvr) + + def _open_dir_button_pressed(self, event): + # selected_path = self.fu.RequestFile(os.path.expanduser("~")) + selected_path = self.fu.RequestDir(os.path.expanduser("~")) + self._widgets["inputTestSourcesFolder"].Text = selected_path + + # main function + def process(self, event): + self.input_dir_path = self._widgets["inputTestSourcesFolder"].Text + project = bmdvr.get_current_project() + otio_timeline = otio_export.create_otio_timeline(project) + print(f"_ otio_timeline: `{otio_timeline}`") + aaf_path = os.path.join(self.input_dir_path, "this_file_name.aaf") + print(f"_ aaf_path: `{aaf_path}`") + # xml_string = otio_adapters.fcpx_xml.write_to_string(otio_timeline) + # print(f"_ xml_string: `{xml_string}`") + otio.adapters.write_to_file( + otio_timeline, aaf_path, adapter_name="AAF") + # at the end close the window + self._close_window(None) + + +if __name__ == "__main__": + test_gui = ThisTestGUI() + test_gui.show_gui() + sys.exit(not bool(True))