Merge pull request #816 from pypeclub/feature/self_contained_tvpaint

Self contained tvpaint
This commit is contained in:
Milan Kolar 2020-12-16 22:08:13 +01:00 committed by GitHub
commit 639efb674f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 90 additions and 64 deletions

View file

@ -1,55 +0,0 @@
import os
import logging
from avalon.tvpaint.communication_server import register_localization_file
from avalon.tvpaint import pipeline
import avalon.api
import pyblish.api
from pype import PLUGINS_DIR
log = logging.getLogger("pype.hosts.tvpaint")
PUBLISH_PATH = os.path.join(PLUGINS_DIR, "tvpaint", "publish")
LOAD_PATH = os.path.join(PLUGINS_DIR, "tvpaint", "load")
CREATE_PATH = os.path.join(PLUGINS_DIR, "tvpaint", "create")
def on_instance_toggle(instance, old_value, new_value):
instance_id = instance.data["uuid"]
found_idx = None
current_instances = pipeline.list_instances()
for idx, workfile_instance in enumerate(current_instances):
if workfile_instance["uuid"] == instance_id:
found_idx = idx
break
if found_idx is None:
return
if "active" in current_instances[found_idx]:
current_instances[found_idx]["active"] = new_value
pipeline._write_instances(current_instances)
def install():
log.info("Pype - Installing TVPaint integration")
current_dir = os.path.dirname(os.path.abspath(__file__))
localization_file = os.path.join(current_dir, "avalon.loc")
register_localization_file(localization_file)
pyblish.api.register_plugin_path(PUBLISH_PATH)
avalon.api.register_plugin_path(avalon.api.Loader, LOAD_PATH)
avalon.api.register_plugin_path(avalon.api.Creator, CREATE_PATH)
registered_callbacks = (
pyblish.api.registered_callbacks().get("instanceToggled") or []
)
if on_instance_toggle not in registered_callbacks:
pyblish.api.register_callback("instanceToggled", on_instance_toggle)
def uninstall():
log.info("Pype - Uninstalling TVPaint integration")
pyblish.api.deregister_plugin_path(PUBLISH_PATH)
avalon.api.deregister_plugin_path(avalon.api.Loader, LOAD_PATH)
avalon.api.deregister_plugin_path(avalon.api.Creator, CREATE_PATH)

View file

@ -0,0 +1,57 @@
import os
import logging
from avalon.tvpaint.communication_server import register_localization_file
from avalon.tvpaint import pipeline
import avalon.api
import pyblish.api
from pype.hosts import tvpaint
log = logging.getLogger("pype.hosts.tvpaint")
HOST_DIR = os.path.dirname(os.path.abspath(tvpaint.__file__))
PLUGINS_DIR = os.path.join(HOST_DIR, "plugins")
PUBLISH_PATH = os.path.join(PLUGINS_DIR, "publish")
LOAD_PATH = os.path.join(PLUGINS_DIR, "load")
CREATE_PATH = os.path.join(PLUGINS_DIR, "create")
def on_instance_toggle(instance, old_value, new_value):
instance_id = instance.data["uuid"]
found_idx = None
current_instances = pipeline.list_instances()
for idx, workfile_instance in enumerate(current_instances):
if workfile_instance["uuid"] == instance_id:
found_idx = idx
break
if found_idx is None:
return
if "active" in current_instances[found_idx]:
current_instances[found_idx]["active"] = new_value
pipeline._write_instances(current_instances)
def install():
log.info("Pype - Installing TVPaint integration")
localization_file = os.path.join(HOST_DIR, "resources", "avalon.loc")
register_localization_file(localization_file)
pyblish.api.register_plugin_path(PUBLISH_PATH)
avalon.api.register_plugin_path(avalon.api.Loader, LOAD_PATH)
avalon.api.register_plugin_path(avalon.api.Creator, CREATE_PATH)
registered_callbacks = (
pyblish.api.registered_callbacks().get("instanceToggled") or []
)
if on_instance_toggle not in registered_callbacks:
pyblish.api.register_callback("instanceToggled", on_instance_toggle)
def uninstall():
log.info("Pype - Uninstalling TVPaint integration")
pyblish.api.deregister_plugin_path(PUBLISH_PATH)
avalon.api.deregister_plugin_path(avalon.api.Loader, LOAD_PATH)
avalon.api.deregister_plugin_path(avalon.api.Creator, CREATE_PATH)

View file

@ -78,7 +78,9 @@ class TvpaintPrelaunchHook(PreLaunchHook):
# TODO add ability to set different template workfile path via
# settings
pype_dir = os.path.dirname(os.path.abspath(tvpaint.__file__))
template_path = os.path.join(pype_dir, "template.tvpp")
template_path = os.path.join(
pype_dir, "resources", "template.tvpp"
)
if not os.path.exists(template_path):
self.log.warning(

View file

@ -16,6 +16,8 @@ from .python_module_tools import (
classes_from_module
)
log = PypeLogger().get_logger(__name__)
class ApplicationNotFound(Exception):
"""Application was not found in ApplicationManager by name."""
@ -575,19 +577,38 @@ class ApplicationLaunchContext:
def paths_to_launch_hooks(self):
"""Directory paths where to look for launch hooks."""
# This method has potential to be part of application manager (maybe).
# TODO find better way how to define dir path to default launch hooks
import pype
pype_dir = os.path.dirname(os.path.abspath(pype.__file__))
hooks_dir = os.path.join(pype_dir, "hooks")
paths = []
# TODO load additional studio paths from settings
# TODO add paths based on used modules (like `ftrack`)
paths = []
subfolder_names = ["global", self.host_name, self.app_name]
import pype
pype_dir = os.path.dirname(os.path.abspath(pype.__file__))
# --- START: Backwards compatibility ---
hooks_dir = os.path.join(pype_dir, "hooks")
subfolder_names = ["global", self.host_name]
for subfolder_name in subfolder_names:
path = os.path.join(hooks_dir, subfolder_name)
if os.path.exists(path) and os.path.isdir(path):
if (
os.path.exists(path)
and os.path.isdir(path)
and path not in paths
):
paths.append(path)
# --- END: Backwards compatibility ---
subfolders_list = (
("hooks", "global"),
("hosts", self.host_name, "hooks")
)
for subfolders in subfolders_list:
path = os.path.join(pype_dir, *subfolders)
if (
os.path.exists(path)
and os.path.isdir(path)
and path not in paths
):
paths.append(path)
return paths

View file

@ -1,4 +1,5 @@
aiohttp
aiohttp_json_rpc
appdirs
arrow
blessed