Merge pull request #5701 from BigRoy/chore/resolve_to_new_style_host

This commit is contained in:
Jakub Ježek 2023-10-06 14:32:44 +02:00 committed by GitHub
commit a67eae9088
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 68 additions and 70 deletions

View file

@ -6,13 +6,10 @@ from .utils import (
)
from .pipeline import (
install,
uninstall,
ResolveHost,
ls,
containerise,
update_container,
publish,
launch_workfiles_app,
maintained_selection,
remove_instance,
list_instances
@ -76,14 +73,10 @@ __all__ = [
"bmdvf",
# pipeline
"install",
"uninstall",
"ResolveHost",
"ls",
"containerise",
"update_container",
"reload_pipeline",
"publish",
"launch_workfiles_app",
"maintained_selection",
"remove_instance",
"list_instances",

View file

@ -5,11 +5,6 @@ from qtpy import QtWidgets, QtCore
from openpype.tools.utils import host_tools
from .pipeline import (
publish,
launch_workfiles_app
)
def load_stylesheet():
path = os.path.join(os.path.dirname(__file__), "menu_style.qss")
@ -113,7 +108,7 @@ class OpenPypeMenu(QtWidgets.QWidget):
def on_workfile_clicked(self):
print("Clicked Workfile")
launch_workfiles_app()
host_tools.show_workfiles()
def on_create_clicked(self):
print("Clicked Create")
@ -121,7 +116,7 @@ class OpenPypeMenu(QtWidgets.QWidget):
def on_publish_clicked(self):
print("Clicked Publish")
publish(None)
host_tools.show_publish(parent=None)
def on_load_clicked(self):
print("Clicked Load")

View file

@ -12,14 +12,24 @@ from openpype.pipeline import (
schema,
register_loader_plugin_path,
register_creator_plugin_path,
deregister_loader_plugin_path,
deregister_creator_plugin_path,
AVALON_CONTAINER_ID,
)
from openpype.tools.utils import host_tools
from openpype.host import (
HostBase,
IWorkfileHost,
ILoadHost
)
from . import lib
from .utils import get_resolve_module
from .workio import (
open_file,
save_file,
file_extensions,
has_unsaved_changes,
work_root,
current_file
)
log = Logger.get_logger(__name__)
@ -32,53 +42,56 @@ CREATE_PATH = os.path.join(PLUGINS_DIR, "create")
AVALON_CONTAINERS = ":AVALON_CONTAINERS"
def install():
"""Install resolve-specific functionality of avalon-core.
class ResolveHost(HostBase, IWorkfileHost, ILoadHost):
name = "resolve"
This is where you install menus and register families, data
and loaders into resolve.
def install(self):
"""Install resolve-specific functionality of avalon-core.
It is called automatically when installing via `api.install(resolve)`.
This is where you install menus and register families, data
and loaders into resolve.
See the Maya equivalent for inspiration on how to implement this.
It is called automatically when installing via `api.install(resolve)`.
"""
See the Maya equivalent for inspiration on how to implement this.
log.info("openpype.hosts.resolve installed")
"""
pyblish.register_host("resolve")
pyblish.register_plugin_path(PUBLISH_PATH)
log.info("Registering DaVinci Resovle plug-ins..")
log.info("openpype.hosts.resolve installed")
register_loader_plugin_path(LOAD_PATH)
register_creator_plugin_path(CREATE_PATH)
pyblish.register_host(self.name)
pyblish.register_plugin_path(PUBLISH_PATH)
print("Registering DaVinci Resolve plug-ins..")
# register callback for switching publishable
pyblish.register_callback("instanceToggled", on_pyblish_instance_toggled)
register_loader_plugin_path(LOAD_PATH)
register_creator_plugin_path(CREATE_PATH)
get_resolve_module()
# register callback for switching publishable
pyblish.register_callback("instanceToggled",
on_pyblish_instance_toggled)
get_resolve_module()
def uninstall():
"""Uninstall all that was installed
def open_workfile(self, filepath):
return open_file(filepath)
This is where you undo everything that was done in `install()`.
That means, removing menus, deregistering families and data
and everything. It should be as though `install()` was never run,
because odds are calling this function means the user is interested
in re-installing shortly afterwards. If, for example, he has been
modifying the menu or registered families.
def save_workfile(self, filepath=None):
return save_file(filepath)
"""
pyblish.deregister_host("resolve")
pyblish.deregister_plugin_path(PUBLISH_PATH)
log.info("Deregistering DaVinci Resovle plug-ins..")
def work_root(self, session):
return work_root(session)
deregister_loader_plugin_path(LOAD_PATH)
deregister_creator_plugin_path(CREATE_PATH)
def get_current_workfile(self):
return current_file()
# register callback for switching publishable
pyblish.deregister_callback("instanceToggled", on_pyblish_instance_toggled)
def workfile_has_unsaved_changes(self):
return has_unsaved_changes()
def get_workfile_extensions(self):
return file_extensions()
def get_containers(self):
return ls()
def containerise(timeline_item,
@ -206,15 +219,6 @@ def update_container(timeline_item, data=None):
return bool(lib.set_timeline_item_pype_tag(timeline_item, container))
def launch_workfiles_app(*args):
host_tools.show_workfiles()
def publish(parent):
"""Shorthand to publish from within host"""
return host_tools.show_publish()
@contextlib.contextmanager
def maintained_selection():
"""Maintain selection during context

View file

@ -17,7 +17,7 @@ def get_resolve_module():
# dont run if already loaded
if api.bmdvr:
log.info(("resolve module is assigned to "
f"`pype.hosts.resolve.api.bmdvr`: {api.bmdvr}"))
f"`openpype.hosts.resolve.api.bmdvr`: {api.bmdvr}"))
return api.bmdvr
try:
"""
@ -41,6 +41,10 @@ def get_resolve_module():
)
elif sys.platform.startswith("linux"):
expected_path = "/opt/resolve/libs/Fusion/Modules"
else:
raise NotImplementedError(
"Unsupported platform: {}".format(sys.platform)
)
# check if the default path has it...
print(("Unable to find module DaVinciResolveScript from "
@ -74,6 +78,6 @@ def get_resolve_module():
api.bmdvr = bmdvr
api.bmdvf = bmdvf
log.info(("Assigning resolve module to "
f"`pype.hosts.resolve.api.bmdvr`: {api.bmdvr}"))
f"`openpype.hosts.resolve.api.bmdvr`: {api.bmdvr}"))
log.info(("Assigning resolve module to "
f"`pype.hosts.resolve.api.bmdvf`: {api.bmdvf}"))
f"`openpype.hosts.resolve.api.bmdvf`: {api.bmdvf}"))

View file

@ -27,7 +27,8 @@ def ensure_installed_host():
if host:
return host
install_host(openpype.hosts.resolve.api)
host = openpype.hosts.resolve.api.ResolveHost()
install_host(host)
return registered_host()
@ -37,10 +38,10 @@ def launch_menu():
openpype.hosts.resolve.api.launch_pype_menu()
def open_file(path):
def open_workfile(path):
# Avoid the need to "install" the host
host = ensure_installed_host()
host.open_file(path)
host.open_workfile(path)
def main():
@ -49,7 +50,7 @@ def main():
if workfile_path and os.path.exists(workfile_path):
log.info(f"Opening last workfile: {workfile_path}")
open_file(workfile_path)
open_workfile(workfile_path)
else:
log.info("No last workfile set to open. Skipping..")

View file

@ -8,12 +8,13 @@ log = Logger.get_logger(__name__)
def main(env):
import openpype.hosts.resolve.api as bmdvr
from openpype.hosts.resolve.api import ResolveHost, launch_pype_menu
# activate resolve from openpype
install_host(bmdvr)
host = ResolveHost()
install_host(host)
bmdvr.launch_pype_menu()
launch_pype_menu()
if __name__ == "__main__":