diff --git a/pype/hosts/resolve/__init__.py b/pype/hosts/resolve/__init__.py index aa0d54ff06..e1e81a4b71 100644 --- a/pype/hosts/resolve/__init__.py +++ b/pype/hosts/resolve/__init__.py @@ -43,6 +43,7 @@ from .api.lib import ( from .api.menu import launch_pype_menu from .api.plugin import ( + ClipLoader, SequenceLoader, Creator, PublishClip @@ -57,9 +58,6 @@ from .api.workio import ( work_root ) -bmdvr = None -bmdvf = None - __all__ = [ # pipeline "install", @@ -105,6 +103,7 @@ __all__ = [ "launch_pype_menu", # plugin + "ClipLoader", "SequenceLoader", "Creator", "PublishClip", diff --git a/pype/hosts/resolve/api/__init__.py b/pype/hosts/resolve/api/__init__.py index 42e92bc109..48bd938e57 100644 --- a/pype/hosts/resolve/api/__init__.py +++ b/pype/hosts/resolve/api/__init__.py @@ -3,6 +3,9 @@ resolve api """ import os +bmdvr = None +bmdvf = None + API_DIR = os.path.dirname(os.path.abspath(__file__)) HOST_DIR = os.path.dirname(API_DIR) PLUGINS_DIR = os.path.join(HOST_DIR, "plugins") diff --git a/pype/hosts/resolve/api/action.py b/pype/hosts/resolve/api/action.py index a9803cef4e..f8f338a850 100644 --- a/pype/hosts/resolve/api/action.py +++ b/pype/hosts/resolve/api/action.py @@ -21,7 +21,7 @@ class SelectInvalidAction(pyblish.api.Action): def process(self, context, plugin): try: - from . import get_project_manager + from .lib import get_project_manager pm = get_project_manager() self.log.debug(pm) except ImportError: diff --git a/pype/hosts/resolve/api/lib.py b/pype/hosts/resolve/api/lib.py index 9e8321b312..a2549eafcd 100644 --- a/pype/hosts/resolve/api/lib.py +++ b/pype/hosts/resolve/api/lib.py @@ -6,7 +6,7 @@ import contextlib from opentimelineio import opentime import pype -from .otio import davinci_export as otio_export +from ..otio import davinci_export as otio_export from pype.api import Logger diff --git a/pype/hosts/resolve/api/pipeline.py b/pype/hosts/resolve/api/pipeline.py index b980c78901..14eb0d4a76 100644 --- a/pype/hosts/resolve/api/pipeline.py +++ b/pype/hosts/resolve/api/pipeline.py @@ -14,18 +14,12 @@ from . import lib from . import PLUGINS_DIR log = Logger().get_logger(__name__) -AVALON_CONFIG = os.environ["AVALON_CONFIG"] - -LOAD_PATH = os.path.join(PLUGINS_DIR, "resolve", "load") -CREATE_PATH = os.path.join(PLUGINS_DIR, "resolve", "create") -INVENTORY_PATH = os.path.join(PLUGINS_DIR, "resolve", "inventory") - -PUBLISH_PATH = os.path.join( - PLUGINS_DIR, "resolve", "publish" -).replace("\\", "/") +PUBLISH_PATH = os.path.join(PLUGINS_DIR, "publish") +LOAD_PATH = os.path.join(PLUGINS_DIR, "load") +CREATE_PATH = os.path.join(PLUGINS_DIR, "create") +INVENTORY_PATH = os.path.join(PLUGINS_DIR, "inventory") AVALON_CONTAINERS = ":AVALON_CONTAINERS" -# IS_HEADLESS = not hasattr(cmds, "about") or cmds.about(batch=True) def install(): @@ -39,7 +33,7 @@ def install(): See the Maya equivalent for inspiration on how to implement this. """ - from . import get_resolve_module + from .. import get_resolve_module # Disable all families except for the ones we explicitly want to see family_states = [ diff --git a/pype/hosts/resolve/api/utils.py b/pype/hosts/resolve/api/utils.py index 2a3f78a2df..32ac5b2aa9 100644 --- a/pype/hosts/resolve/api/utils.py +++ b/pype/hosts/resolve/api/utils.py @@ -7,7 +7,7 @@ Resolve's tools for setting environment import sys import os import shutil - +from . import HOST_DIR from pype.api import Logger log = Logger().get_logger(__name__) @@ -15,10 +15,10 @@ log = Logger().get_logger(__name__) def get_resolve_module(): from pype.hosts import resolve # dont run if already loaded - if resolve.bmdvr: + if resolve.api.bmdvr: log.info(("resolve module is assigned to " - f"`pype.hosts.resolve.bmdvr`: {resolve.bmdvr}")) - return resolve.bmdvr + f"`pype.hosts.resolve.api.bmdvr`: {resolve.api.bmdvr}")) + return resolve.api.bmdvr try: """ The PYTHONPATH needs to be set correctly for this import @@ -71,12 +71,12 @@ def get_resolve_module(): # assign global var and return bmdvr = bmd.scriptapp("Resolve") # bmdvf = bmd.scriptapp("Fusion") - resolve.bmdvr = bmdvr - resolve.bmdvf = bmdvr.Fusion() + resolve.api.bmdvr = bmdvr + resolve.api.bmdvf = bmdvr.Fusion() log.info(("Assigning resolve module to " - f"`pype.hosts.resolve.bmdvr`: {resolve.bmdvr}")) + f"`pype.hosts.resolve.api.bmdvr`: {resolve.api.bmdvr}")) log.info(("Assigning resolve module to " - f"`pype.hosts.resolve.bmdvf`: {resolve.bmdvf}")) + f"`pype.hosts.resolve.api.bmdvf`: {resolve.api.bmdvf}")) def _sync_utility_scripts(env=None): @@ -93,7 +93,7 @@ def _sync_utility_scripts(env=None): us_env = env.get("RESOLVE_UTILITY_SCRIPTS_SOURCE_DIR") us_dir = env.get("RESOLVE_UTILITY_SCRIPTS_DIR", "") us_paths = [os.path.join( - os.path.dirname(__file__), + HOST_DIR, "utility_scripts" )] @@ -115,7 +115,10 @@ def _sync_utility_scripts(env=None): for s in os.listdir(us_dir): path = os.path.join(us_dir, s) log.info(f"Removing `{path}`...") - os.remove(path) + if os.path.isdir(path): + shutil.rmtree(path, onerror=None) + else: + os.remove(path) # copy scripts into Resolve's utility scripts dir for d, sl in scripts.items(): @@ -125,7 +128,13 @@ def _sync_utility_scripts(env=None): src = os.path.join(d, s) dst = os.path.join(us_dir, s) log.info(f"Copying `{src}` to `{dst}`...") - shutil.copy2(src, dst) + if os.path.isdir(src): + shutil.copytree( + src, dst, symlinks=False, + ignore=None, ignore_dangling_symlinks=False + ) + else: + shutil.copy2(src, dst) def setup(env=None): diff --git a/pype/hosts/resolve/api/workio.py b/pype/hosts/resolve/api/workio.py index 18936df018..59381ae50c 100644 --- a/pype/hosts/resolve/api/workio.py +++ b/pype/hosts/resolve/api/workio.py @@ -2,7 +2,7 @@ import os from pype.api import Logger -from . import ( +from .. import ( get_project_manager, get_current_project, set_project_manager_to_folder_name diff --git a/pype/hooks/resolve/pre_resolve_setup.py b/pype/hosts/resolve/hooks/pre_resolve_setup.py similarity index 98% rename from pype/hooks/resolve/pre_resolve_setup.py rename to pype/hosts/resolve/hooks/pre_resolve_setup.py index 19a0817a0d..d19c56fe09 100644 --- a/pype/hooks/resolve/pre_resolve_setup.py +++ b/pype/hosts/resolve/hooks/pre_resolve_setup.py @@ -1,7 +1,7 @@ import os import importlib from pype.lib import PreLaunchHook -from pype.hosts.resolve import utils +from pype.hosts.resolve.api import utils class ResolvePrelaunch(PreLaunchHook): diff --git a/pype/hosts/resolve/plugins/load/load_sequence.py b/pype/hosts/resolve/plugins/load/load_sequence.py index 6cbda26025..735f60dcff 100644 --- a/pype/hosts/resolve/plugins/load/load_sequence.py +++ b/pype/hosts/resolve/plugins/load/load_sequence.py @@ -33,7 +33,7 @@ class LoadClip(resolve.SequenceLoader): }) # load clip to timeline and get main variables - timeline_item = resolve.plugin.ClipLoader( + timeline_item = resolve.ClipLoader( self, context, **options).load() namespace = namespace or timeline_item.GetName() version = context['version'] diff --git a/pype/hosts/resolve/plugins/publish/collect_instances.py b/pype/hosts/resolve/plugins/publish/collect_instances.py index 76332b03c2..b1eafd512e 100644 --- a/pype/hosts/resolve/plugins/publish/collect_instances.py +++ b/pype/hosts/resolve/plugins/publish/collect_instances.py @@ -14,20 +14,20 @@ class CollectInstances(pyblish.api.ContextPlugin): def process(self, context): otio_timeline = context.data["otioTimeline"] - selected_track_items = resolve.get_current_track_items( + selected_timeline_items = resolve.get_current_timeline_items( filter=True, selecting_color=resolve.publish_clip_color) self.log.info( "Processing enabled track items: {}".format( - len(selected_track_items))) + len(selected_timeline_items))) - for track_item_data in selected_track_items: + for timeline_item_data in selected_timeline_items: data = dict() - track_item = track_item_data["clip"]["item"] + timeline_item = timeline_item_data["clip"]["item"] # get pype tag data - tag_data = resolve.get_track_item_pype_tag(track_item) + tag_data = resolve.get_timeline_item_pype_tag(timeline_item) self.log.debug(f"__ tag_data: {pformat(tag_data)}") if not tag_data: @@ -36,7 +36,7 @@ class CollectInstances(pyblish.api.ContextPlugin): if tag_data.get("id") != "pyblish.avalon.instance": continue - media_pool_item = track_item.GetMediaPoolItem() + media_pool_item = timeline_item.GetMediaPoolItem() clip_property = media_pool_item.GetClipProperty() self.log.debug(f"clip_property: {clip_property}") @@ -57,15 +57,15 @@ class CollectInstances(pyblish.api.ContextPlugin): data.update({ "name": "{} {} {}".format(asset, subset, families), "asset": asset, - "item": track_item, + "item": timeline_item, "families": families, - "publish": resolve.get_publish_attribute(track_item), + "publish": resolve.get_publish_attribute(timeline_item), "fps": context.data["fps"] }) # otio clip data otio_data = resolve.get_otio_clip_instance_data( - otio_timeline, track_item_data) or {} + otio_timeline, timeline_item_data) or {} data.update(otio_data) # add resolution @@ -75,7 +75,7 @@ class CollectInstances(pyblish.api.ContextPlugin): instance = context.create_instance(**data) # create shot instance for shot attributes create/update - self.create_shot_instance(context, track_item, **data) + self.create_shot_instance(context, timeline_item, **data) self.log.info("Creating instance: {}".format(instance)) self.log.debug( @@ -101,7 +101,7 @@ class CollectInstances(pyblish.api.ContextPlugin): "pixelAspect": otio_tl_metadata["pixelAspect"] }) - def create_shot_instance(self, context, track_item, **data): + def create_shot_instance(self, context, timeline_item, **data): master_layer = data.get("masterLayer") hierarchy_data = data.get("hierarchyData") @@ -123,7 +123,7 @@ class CollectInstances(pyblish.api.ContextPlugin): "asset": asset, "family": family, "families": [], - "publish": resolve.get_publish_attribute(track_item) + "publish": resolve.get_publish_attribute(timeline_item) }) context.create_instance(**data)