fix(resolve): transition to new structure

This commit is contained in:
Jakub Jezek 2020-06-12 13:03:10 +03:00
parent 6b0cb54ae5
commit ae7a655513
No known key found for this signature in database
GPG key ID: C4B96E101D2A47F3
8 changed files with 13 additions and 170 deletions

View file

@ -46,13 +46,14 @@ class ResolvePrelaunch(PypeHook):
"`RESOLVE_UTILITY_SCRIPTS_DIR` or reinstall DaVinci Resolve. \n"
f"RESOLVE_UTILITY_SCRIPTS_DIR: `{us_dir}`"
)
self.log.debug(f"-- us_dir: `{us_dir}`")
# correctly format path for pre python script
pre_py_sc = os.path.normpath(env.get("PRE_PYTHON_SCRIPT", ""))
env["PRE_PYTHON_SCRIPT"] = pre_py_sc
self.log.debug(f"-- pre_py_sc: `{pre_py_sc}`...")
try:
__import__("pype.resolve")
__import__("pype.hosts.resolve")
__import__("pyblish")
except ImportError as e:
@ -62,6 +63,7 @@ class ResolvePrelaunch(PypeHook):
else:
# Resolve Setup integration
importlib.reload(utils)
self.log.debug(f"-- utils.__file__: `{utils.__file__}`")
utils.setup(env)
return True

View file

@ -1,6 +1,6 @@
import sys
from .utils import get_resolve_module
from pypeapp import Logger
from pype.api import Logger
log = Logger().get_logger(__name__, "resolve")

View file

@ -6,23 +6,21 @@ import os
from avalon.tools import workfiles
from avalon import api as avalon
from pyblish import api as pyblish
from pypeapp import Logger
import pype
from pype.api import Logger
log = Logger().get_logger(__name__, "resolve")
# self = sys.modules[__name__]
AVALON_CONFIG = os.environ["AVALON_CONFIG"]
PARENT_DIR = os.path.dirname(__file__)
PACKAGE_DIR = os.path.dirname(PARENT_DIR)
PLUGINS_DIR = os.path.join(PACKAGE_DIR, "plugins")
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")
LOAD_PATH = os.path.join(pype.PLUGINS_DIR, "resolve", "load")
CREATE_PATH = os.path.join(pype.PLUGINS_DIR, "resolve", "create")
INVENTORY_PATH = os.path.join(pype.PLUGINS_DIR, "resolve", "inventory")
PUBLISH_PATH = os.path.join(
PLUGINS_DIR, "resolve", "publish"
pype.PLUGINS_DIR, "resolve", "publish"
).replace("\\", "/")
AVALON_CONTAINERS = ":AVALON_CONTAINERS"

View file

@ -1,7 +1,7 @@
#!/usr/bin/env python
import time
from pype.hosts.resolve.utils import get_resolve_module
from pypeapp import Logger
from pype.api import Logger
log = Logger().get_logger(__name__, "resolve")

View file

@ -3,7 +3,7 @@ import sys
import avalon.api as avalon
import pype
from pypeapp import Logger
from pype.api import Logger
log = Logger().get_logger(__name__)

View file

@ -1,65 +0,0 @@
#! python3
# -*- coding: utf-8 -*-
# convert clip def
def convert_clip(timeline=None):
"""Convert timeline item (clip) into compound clip pype container
Args:
timeline (MediaPool.Timeline): Object of timeline
Returns:
bool: `True` if success
Raises:
Exception: description
"""
pass
# decorator function create_current_timeline_media_bin()
def create_current_timeline_media_bin(timeline=None):
"""Convert timeline item (clip) into compound clip pype container
Args:
timeline (MediaPool.Timeline): Object of timeline
Returns:
bool: `True` if success
Raises:
Exception: description
"""
pass
# decorator function get_selected_track_items()
def get_selected_track_items():
"""Convert timeline item (clip) into compound clip pype container
Args:
timeline (MediaPool.Timeline): Object of timeline
Returns:
bool: `True` if success
Raises:
Exception: description
"""
print("testText")
# PypeCompoundClip() class
class PypeCompoundClip(object):
"""docstring for ."""
def __init__(self, arg):
super(self).__init__()
self.arg = arg
def create_compound_clip(self):
pass

View file

@ -1,57 +0,0 @@
import os
import sys
import pype
import importlib
import pyblish.api
import pyblish.util
import avalon.api
from avalon.tools import publish
from pypeapp import Logger
log = Logger().get_logger(__name__)
def main(env):
# Registers pype's Global pyblish plugins
pype.install()
# Register Host (and it's pyblish plugins)
host_name = env["AVALON_APP"]
# TODO not sure if use "pype." or "avalon." for host import
host_import_str = f"pype.{host_name}"
try:
host_module = importlib.import_module(host_import_str)
except ModuleNotFoundError:
log.error((
f"Host \"{host_name}\" can't be imported."
f" Import string \"{host_import_str}\" failed."
))
return False
avalon.api.install(host_module)
# Register additional paths
addition_paths_str = env.get("PUBLISH_PATHS") or ""
addition_paths = addition_paths_str.split(os.pathsep)
for path in addition_paths:
path = os.path.normpath(path)
if not os.path.exists(path):
continue
pyblish.api.register_plugin_path(path)
# Register project specific plugins
project_name = os.environ["AVALON_PROJECT"]
project_plugins_paths = env.get("PYPE_PROJECT_PLUGINS") or ""
for path in project_plugins_paths.split(os.pathsep):
plugin_path = os.path.join(path, project_name, "plugins")
if os.path.exists(plugin_path):
pyblish.api.register_plugin_path(plugin_path)
return publish.show()
if __name__ == "__main__":
result = main(os.environ)
sys.exit(not bool(result))

View file

@ -1,35 +0,0 @@
#! python3
# -*- coding: utf-8 -*-
import os
from pypeapp import execute, Logger
from pype.hosts.resolve.utils import get_resolve_module
log = Logger().get_logger("Resolve")
CURRENT_DIR = os.getenv("RESOLVE_UTILITY_SCRIPTS_DIR", "")
python_dir = os.getenv("PYTHON36_RESOLVE")
python_exe = os.path.normpath(
os.path.join(python_dir, "python.exe")
)
resolve = get_resolve_module()
PM = resolve.GetProjectManager()
P = PM.GetCurrentProject()
log.info(P.GetName())
# ______________________________________________________
# testing subprocessing Scripts
testing_py = os.path.join(CURRENT_DIR, "ResolvePageSwitcher.py")
testing_py = os.path.normpath(testing_py)
log.info(f"Testing path to script: `{testing_py}`")
returncode = execute(
[python_exe, os.path.normpath(testing_py)],
env=dict(os.environ)
)
# Check if output file exists
if returncode != 0:
log.error("Executing failed!")