mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
feat(resolve): updating resolve integration
This commit is contained in:
parent
0b4c4d017b
commit
1dc624cdc6
8 changed files with 176 additions and 23 deletions
|
|
@ -26,8 +26,28 @@ class ResolvePrelaunch(PypeHook):
|
|||
if not env:
|
||||
env = os.environ
|
||||
|
||||
env["PRE_PYTHON_SCRIPT"] = os.path.normpath(env["PRE_PYTHON_SCRIPT"])
|
||||
self.log.info(env["PRE_PYTHON_SCRIPT"])
|
||||
# making sure pyton 3.6 is installed at provided path
|
||||
py36_dir = os.path.normpath(env.get("PYTHON36_RES", ""))
|
||||
assert os.path.isdir(py36_dir), (
|
||||
"Python 3.6 is not installed at the provided folder path. Either "
|
||||
"make sure the `environments\resolve.json` is having correctly set "
|
||||
"`PYTHON36_RES` or make sure Python 3.6 is installed in given path."
|
||||
f"\nPYTHON36_RES: `{py36_dir}`"
|
||||
)
|
||||
env["PYTHON36_RES"] = py36_dir
|
||||
|
||||
# setting utility scripts dir for scripts syncing
|
||||
us_dir = os.path.normpath(env.get("RESOLVE_UTILITY_SCRIPTS_DIR", ""))
|
||||
assert os.path.isdir(us_dir), (
|
||||
"Resolve utility script dir does not exists. Either make sure "
|
||||
"the `environments\resolve.json` is having correctly set "
|
||||
"`RESOLVE_UTILITY_SCRIPTS_DIR` or reinstall DaVinci Resolve. \n"
|
||||
f"RESOLVE_UTILITY_SCRIPTS_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
|
||||
|
||||
try:
|
||||
__import__("pype.resolve")
|
||||
|
|
@ -39,7 +59,6 @@ class ResolvePrelaunch(PypeHook):
|
|||
|
||||
else:
|
||||
# Resolve Setup integration
|
||||
# importlib.reload(prlib)
|
||||
rlib.setup(env)
|
||||
|
||||
return True
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ from .lib import (
|
|||
setup,
|
||||
reload_pipeline,
|
||||
ls,
|
||||
LOAD_PATH,
|
||||
CREATE_PATH,
|
||||
# LOAD_PATH,
|
||||
# CREATE_PATH,
|
||||
PUBLISH_PATH
|
||||
)
|
||||
|
||||
|
|
@ -48,8 +48,8 @@ def install():
|
|||
pyblish.register_plugin_path(PUBLISH_PATH)
|
||||
log.info("Registering Premiera plug-ins..")
|
||||
|
||||
avalon.register_plugin_path(avalon.Loader, LOAD_PATH)
|
||||
avalon.register_plugin_path(avalon.Creator, CREATE_PATH)
|
||||
# avalon.register_plugin_path(avalon.Loader, LOAD_PATH)
|
||||
# avalon.register_plugin_path(avalon.Creator, CREATE_PATH)
|
||||
|
||||
|
||||
def uninstall():
|
||||
|
|
@ -67,5 +67,5 @@ def uninstall():
|
|||
pyblish.deregister_plugin_path(PUBLISH_PATH)
|
||||
log.info("Deregistering Premiera plug-ins..")
|
||||
|
||||
avalon.deregister_plugin_path(avalon.Loader, LOAD_PATH)
|
||||
avalon.deregister_plugin_path(avalon.Creator, CREATE_PATH)
|
||||
# avalon.deregister_plugin_path(avalon.Loader, LOAD_PATH)
|
||||
# avalon.deregister_plugin_path(avalon.Creator, CREATE_PATH)
|
||||
|
|
|
|||
|
|
@ -1,34 +1,21 @@
|
|||
import os
|
||||
import sys
|
||||
import shutil
|
||||
import json
|
||||
from pysync import walktree
|
||||
import requests
|
||||
|
||||
from avalon import api
|
||||
from pype.widgets.message_window import message
|
||||
from pypeapp import Logger
|
||||
|
||||
|
||||
log = Logger().get_logger(__name__, "resolve")
|
||||
|
||||
self = sys.modules[__name__]
|
||||
self._has_been_setup = False
|
||||
self._registered_gui = None
|
||||
|
||||
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")
|
||||
|
||||
self.EXTENSIONS_PATH_REMOTE = os.path.join(PARENT_DIR, "extensions")
|
||||
self.EXTENSIONS_PATH_LOCAL = None
|
||||
self.EXTENSIONS_CACHE_PATH = None
|
||||
|
||||
self.LOAD_PATH = os.path.join(PLUGINS_DIR, "resolve", "load")
|
||||
self.CREATE_PATH = os.path.join(PLUGINS_DIR, "resolve", "create")
|
||||
self.INVENTORY_PATH = os.path.join(PLUGINS_DIR, "resolve", "inventory")
|
||||
self.UTILITY_SCRIPTS = os.path.join(PARENT_DIR, "resolve_utility_scripts")
|
||||
|
||||
self.PUBLISH_PATH = os.path.join(
|
||||
PLUGINS_DIR, "resolve", "publish"
|
||||
|
|
@ -48,6 +35,36 @@ def ls():
|
|||
pass
|
||||
|
||||
|
||||
def sync_utility_scripts(env=None):
|
||||
""" Synchronizing basic utlility scripts for resolve.
|
||||
|
||||
To be able to run scripts from inside `Resolve/Workspace/Scripts` menu
|
||||
all scripts has to be accessible from defined folder.
|
||||
"""
|
||||
if not env:
|
||||
env = os.environ
|
||||
|
||||
us_dir = env.get("RESOLVE_UTILITY_SCRIPTS_DIR", "")
|
||||
scripts = os.listdir(self.UTILITY_SCRIPTS)
|
||||
|
||||
log.info(f"Utility Scripts Dir: `{self.UTILITY_SCRIPTS}`")
|
||||
log.info(f"Utility Scripts: `{scripts}`")
|
||||
|
||||
# make sure no script file is in folder
|
||||
if next((s for s in os.listdir(us_dir)), None):
|
||||
for s in os.listdir(us_dir):
|
||||
path = os.path.join(us_dir, s)
|
||||
log.info(f"Removing `{path}`...")
|
||||
os.remove(path)
|
||||
|
||||
# copy scripts into Resolve's utility scripts dir
|
||||
for s in scripts:
|
||||
src = os.path.join(self.UTILITY_SCRIPTS, s)
|
||||
dst = os.path.join(us_dir, s)
|
||||
log.info(f"Copying `{src}` to `{dst}`...")
|
||||
shutil.copy2(src, dst)
|
||||
|
||||
|
||||
def reload_pipeline():
|
||||
"""Attempt to reload pipeline at run-time.
|
||||
|
||||
|
|
@ -86,4 +103,7 @@ def setup(env=None):
|
|||
if not env:
|
||||
env = os.environ
|
||||
|
||||
# synchronize resolve utility scripts
|
||||
sync_utility_scripts(env)
|
||||
|
||||
log.info("Resolve Pype wrapper has been installed")
|
||||
|
|
|
|||
72
pype/resolve/resolve_utility_scripts/resolveapitest.py
Normal file
72
pype/resolve/resolve_utility_scripts/resolveapitest.py
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
#! /usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# This script tests Resolve 15 scripting API on MacOS.
|
||||
# We suspect an issue with import of fusionscript.so.
|
||||
# To test launch Resolve Studio first and then run this script.
|
||||
# The script will save a text report.
|
||||
# igor@hdhead.com
|
||||
|
||||
from datetime import datetime
|
||||
import os
|
||||
import sys
|
||||
import imp
|
||||
|
||||
eol = '\n'
|
||||
pathLib = 'C:\\Program Files\\Blackmagic Design\\DaVinci Resolve\\fusionscript.dll'
|
||||
|
||||
reportDir = "C:\\Users\\jezsc"
|
||||
|
||||
# Create initial report file. It will overwrite existing!
|
||||
reportName = 'Resolve_API_Report.txt'
|
||||
reportPath = os.path.join(reportDir, reportName)
|
||||
reportfile = open(reportPath, 'w')
|
||||
reportfile.close()
|
||||
|
||||
|
||||
def report(entry):
|
||||
# Print to console
|
||||
print entry
|
||||
|
||||
# Write a report entry
|
||||
reportfile = open(reportPath, 'a')
|
||||
reportfile.write(entry)
|
||||
reportfile.write(eol)
|
||||
reportfile.close()
|
||||
|
||||
|
||||
# These are the values we'll discover and save
|
||||
report('Time: ' + str(datetime.now()))
|
||||
report('Python Version: ' + sys.version)
|
||||
report('Interpreter Path: ' + sys.executable)
|
||||
report('___________________________________' + eol)
|
||||
|
||||
report('If no lines follow we have likely experienced a Fatal Python Error.')
|
||||
|
||||
try:
|
||||
# Will the API library import? Does it exist?
|
||||
smodule = imp.load_dynamic('fusionscript', pathLib)
|
||||
report('Imported fusionscript.so')
|
||||
|
||||
# It looks like the library imported. Can we create a resolve instance now?
|
||||
try:
|
||||
resolve = smodule.scriptapp('Resolve')
|
||||
if 'None' in str(type(resolve)):
|
||||
report('Resolve instance is created, but Resolve is not found.')
|
||||
sys.exit()
|
||||
if 'PyRemoteObject' in str(type(resolve)):
|
||||
report('Resolve instance is created and Resolve is responsive.')
|
||||
except Exception, e:
|
||||
report(str(e))
|
||||
|
||||
# Let's go nuts and count how many projects are in the Project Manager
|
||||
try:
|
||||
projman = resolve.GetProjectManager()
|
||||
projects = projman.GetProjectsInCurrentFolder()
|
||||
report('Project Count: ' + str(len(projects)))
|
||||
report('All is well!')
|
||||
except Exception, e:
|
||||
report(str(e))
|
||||
|
||||
except Exception, e:
|
||||
report(str(e))
|
||||
8
pype/resolve/resolve_utility_scripts/test.py
Normal file
8
pype/resolve/resolve_utility_scripts/test.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#!/usr/bin/env python3.6
|
||||
from python_get_resolve import GetResolve
|
||||
|
||||
resolve = GetResolve()
|
||||
PM = resolve.GetProjectManager()
|
||||
P = PM.GetCurrentProject()
|
||||
|
||||
print(P.GetName())
|
||||
34
pype/resolve/utility/python_get_resolve.py
Normal file
34
pype/resolve/utility/python_get_resolve.py
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
This file serves to return a DaVinci Resolve object
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
||||
def GetResolve():
|
||||
try:
|
||||
# The PYTHONPATH needs to be set correctly for this import statement to work.
|
||||
# An alternative is to import the DaVinciResolveScript by specifying absolute path (see ExceptionHandler logic)
|
||||
import DaVinciResolveScript as bmd
|
||||
except ImportError:
|
||||
if sys.platform.startswith("darwin"):
|
||||
expectedPath="/Library/Application Support/Blackmagic Design/DaVinci Resolve/Developer/Scripting/Modules/"
|
||||
elif sys.platform.startswith("win") or sys.platform.startswith("cygwin"):
|
||||
import os
|
||||
expectedPath=os.getenv('PROGRAMDATA') + "\\Blackmagic Design\\DaVinci Resolve\\Support\\Developer\\Scripting\\Modules\\"
|
||||
elif sys.platform.startswith("linux"):
|
||||
expectedPath="/opt/resolve/libs/Fusion/Modules/"
|
||||
|
||||
# check if the default path has it...
|
||||
print("Unable to find module DaVinciResolveScript from $PYTHONPATH - trying default locations")
|
||||
try:
|
||||
import imp
|
||||
bmd = imp.load_source('DaVinciResolveScript', expectedPath+"DaVinciResolveScript.py")
|
||||
except ImportError:
|
||||
# No fallbacks ... report error:
|
||||
print("Unable to find module DaVinciResolveScript - please ensure that the module DaVinciResolveScript is discoverable by python")
|
||||
print("For a default DaVinci Resolve installation, the module is expected to be located in: "+expectedPath)
|
||||
sys.exit()
|
||||
|
||||
return bmd.scriptapp("Resolve")
|
||||
Loading…
Add table
Add a link
Reference in a new issue