mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
fixed registered host callbacks
This commit is contained in:
parent
578a0469c9
commit
905eccdc41
19 changed files with 60 additions and 42 deletions
|
|
@ -4,17 +4,18 @@ from Qt import QtWidgets
|
|||
from pprint import pformat
|
||||
import atexit
|
||||
|
||||
import avalon
|
||||
import openpype.hosts.flame.api as opfapi
|
||||
from openpype.pipeline import install_host
|
||||
from openpype.pipeline import (
|
||||
install_host,
|
||||
registered_host,
|
||||
)
|
||||
|
||||
|
||||
def openpype_install():
|
||||
"""Registering OpenPype in context
|
||||
"""
|
||||
install_host(opfapi)
|
||||
print("Avalon registered hosts: {}".format(
|
||||
avalon.api.registered_host()))
|
||||
print("Avalon registered hosts: {}".format(registered_host()))
|
||||
|
||||
|
||||
# Exception handler
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import avalon.api as api
|
||||
import pyblish.api
|
||||
|
||||
from openpype.pipeline import registered_host
|
||||
|
||||
|
||||
def collect_input_containers(nodes):
|
||||
"""Collect containers that contain any of the node in `nodes`.
|
||||
|
|
@ -18,7 +19,7 @@ def collect_input_containers(nodes):
|
|||
lookup = frozenset(nodes)
|
||||
|
||||
containers = []
|
||||
host = api.registered_host()
|
||||
host = registered_host()
|
||||
for container in host.ls():
|
||||
|
||||
node = container["node"]
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import pyblish.api
|
||||
import avalon.api
|
||||
|
||||
from openpype.api import version_up
|
||||
from openpype.action import get_errored_plugins_from_data
|
||||
from openpype.pipeline import registered_host
|
||||
|
||||
|
||||
class IncrementCurrentFile(pyblish.api.InstancePlugin):
|
||||
|
|
@ -41,7 +41,7 @@ class IncrementCurrentFile(pyblish.api.InstancePlugin):
|
|||
)
|
||||
|
||||
# Filename must not have changed since collecting
|
||||
host = avalon.api.registered_host()
|
||||
host = registered_host()
|
||||
current_file = host.current_file()
|
||||
assert (
|
||||
context.data["currentFile"] == current_file
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import pyblish.api
|
||||
import avalon.api
|
||||
|
||||
from openpype.pipeline import registered_host
|
||||
|
||||
|
||||
class SaveCurrentScene(pyblish.api.ContextPlugin):
|
||||
|
|
@ -12,7 +13,7 @@ class SaveCurrentScene(pyblish.api.ContextPlugin):
|
|||
def process(self, context):
|
||||
|
||||
# Filename must not have changed since collecting
|
||||
host = avalon.api.registered_host()
|
||||
host = registered_host()
|
||||
current_file = host.current_file()
|
||||
assert context.data['currentFile'] == current_file, (
|
||||
"Collected filename from current scene name."
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ from openpype.pipeline import (
|
|||
loaders_from_representation,
|
||||
get_representation_path,
|
||||
load_container,
|
||||
registered_host,
|
||||
)
|
||||
from .commands import reset_frame_range
|
||||
|
||||
|
|
@ -1574,7 +1575,7 @@ def assign_look_by_version(nodes, version_id):
|
|||
"name": "json"})
|
||||
|
||||
# See if representation is already loaded, if so reuse it.
|
||||
host = api.registered_host()
|
||||
host = registered_host()
|
||||
representation_id = str(look_representation['_id'])
|
||||
for container in host.ls():
|
||||
if (container['loader'] == "LookLoader" and
|
||||
|
|
@ -2612,7 +2613,7 @@ def get_attr_in_layer(attr, layer):
|
|||
def fix_incompatible_containers():
|
||||
"""Backwards compatibility: old containers to use new ReferenceLoader"""
|
||||
|
||||
host = api.registered_host()
|
||||
host = registered_host()
|
||||
for container in host.ls():
|
||||
loader = container['loader']
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ from Qt import QtWidgets
|
|||
from bson.objectid import ObjectId
|
||||
|
||||
import pyblish.api
|
||||
import avalon.api
|
||||
from avalon import io
|
||||
|
||||
from openpype.api import Logger
|
||||
|
|
@ -14,6 +13,7 @@ from openpype.pipeline import (
|
|||
deregister_loader_plugin_path,
|
||||
deregister_creator_plugin_path,
|
||||
AVALON_CONTAINER_ID,
|
||||
registered_host,
|
||||
)
|
||||
import openpype.hosts.photoshop
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ def check_inventory():
|
|||
if not lib.any_outdated():
|
||||
return
|
||||
|
||||
host = avalon.api.registered_host()
|
||||
host = registered_host()
|
||||
outdated_containers = []
|
||||
for container in host.ls():
|
||||
representation = container['representation']
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
import os
|
||||
|
||||
from avalon import api, io
|
||||
from avalon import io
|
||||
from openpype.lib import (
|
||||
StringTemplate,
|
||||
get_workfile_template_key_from_context,
|
||||
get_workdir_data,
|
||||
get_last_workfile_with_version,
|
||||
)
|
||||
from openpype.pipeline import registered_host
|
||||
from openpype.api import Anatomy
|
||||
from openpype.hosts.tvpaint.api import lib, pipeline, plugin
|
||||
|
||||
|
|
@ -22,7 +23,7 @@ class LoadWorkfile(plugin.Loader):
|
|||
def load(self, context, name, namespace, options):
|
||||
# Load context of current workfile as first thing
|
||||
# - which context and extension has
|
||||
host = api.registered_host()
|
||||
host = registered_host()
|
||||
current_file = host.current_file()
|
||||
|
||||
context = pipeline.get_current_workfile_context()
|
||||
|
|
|
|||
|
|
@ -161,9 +161,10 @@ def is_latest(representation):
|
|||
@with_avalon
|
||||
def any_outdated():
|
||||
"""Return whether the current scene has any outdated content"""
|
||||
from openpype.pipeline import registered_host
|
||||
|
||||
checked = set()
|
||||
host = avalon.api.registered_host()
|
||||
host = registered_host()
|
||||
for container in host.ls():
|
||||
representation = container['representation']
|
||||
if representation in checked:
|
||||
|
|
|
|||
|
|
@ -356,7 +356,7 @@ class CreatedInstance:
|
|||
already existing instance.
|
||||
creator(BaseCreator): Creator responsible for instance.
|
||||
host(ModuleType): Host implementation loaded with
|
||||
`avalon.api.registered_host`.
|
||||
`openpype.pipeline.registered_host`.
|
||||
new(bool): Is instance new.
|
||||
"""
|
||||
# Keys that can't be changed or removed from data after loading using
|
||||
|
|
|
|||
|
|
@ -142,7 +142,8 @@ def legacy_create(Creator, name, asset, options=None, data=None):
|
|||
Name of instance
|
||||
|
||||
"""
|
||||
from avalon.api import registered_host
|
||||
from openpype.pipeline import registered_host
|
||||
|
||||
host = registered_host()
|
||||
plugin = Creator(name, asset, options, data)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
from bson.objectid import ObjectId
|
||||
|
||||
import pyblish.api
|
||||
from avalon import api, io
|
||||
from avalon import io
|
||||
from openpype.pipeline import registered_host
|
||||
|
||||
|
||||
class CollectSceneLoadedVersions(pyblish.api.ContextPlugin):
|
||||
|
|
@ -24,7 +25,7 @@ class CollectSceneLoadedVersions(pyblish.api.ContextPlugin):
|
|||
]
|
||||
|
||||
def process(self, context):
|
||||
host = api.registered_host()
|
||||
host = registered_host()
|
||||
if host is None:
|
||||
self.log.warn("No registered host.")
|
||||
return
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import avalon.fusion
|
|||
|
||||
# Config imports
|
||||
import openpype.lib as pype
|
||||
from openpype.pipeline import registered_host
|
||||
import openpype.hosts.fusion.lib as fusion_lib
|
||||
|
||||
from openpype.lib.avalon_context import get_workdir_from_session
|
||||
|
|
@ -176,7 +177,7 @@ def switch(asset_name, filepath=None, new=True):
|
|||
current_comp = fusion.LoadComp(filepath, quiet=True)
|
||||
assert current_comp is not None, "Fusion could not load '%s'" % filepath
|
||||
|
||||
host = api.registered_host()
|
||||
host = registered_host()
|
||||
containers = list(host.ls())
|
||||
assert containers, "Nothing to update"
|
||||
|
||||
|
|
|
|||
|
|
@ -5,9 +5,12 @@ import os
|
|||
from bson.objectid import ObjectId
|
||||
import maya.cmds as cmds
|
||||
|
||||
from avalon import io, api
|
||||
from avalon import io
|
||||
|
||||
from openpype.pipeline import remove_container
|
||||
from openpype.pipeline import (
|
||||
remove_container,
|
||||
registered_host,
|
||||
)
|
||||
from openpype.hosts.maya.api import lib
|
||||
|
||||
from .vray_proxies import get_alembic_ids_cache
|
||||
|
|
@ -79,7 +82,7 @@ def get_all_asset_nodes():
|
|||
list: list of dictionaries
|
||||
"""
|
||||
|
||||
host = api.registered_host()
|
||||
host = registered_host()
|
||||
|
||||
nodes = []
|
||||
for container in host.ls():
|
||||
|
|
@ -192,7 +195,7 @@ def remove_unused_looks():
|
|||
|
||||
"""
|
||||
|
||||
host = api.registered_host()
|
||||
host = registered_host()
|
||||
|
||||
unused = []
|
||||
for container in host.ls():
|
||||
|
|
|
|||
|
|
@ -11,13 +11,14 @@ from bson.objectid import ObjectId
|
|||
import alembic.Abc
|
||||
from maya import cmds
|
||||
|
||||
from avalon import io, api
|
||||
from avalon import io
|
||||
|
||||
from openpype.pipeline import (
|
||||
load_container,
|
||||
loaders_from_representation,
|
||||
discover_loader_plugins,
|
||||
get_representation_path,
|
||||
registered_host,
|
||||
)
|
||||
from openpype.hosts.maya.api import lib
|
||||
|
||||
|
|
@ -188,7 +189,7 @@ def load_look(version_id):
|
|||
"name": "ma"})
|
||||
|
||||
# See if representation is already loaded, if so reuse it.
|
||||
host = api.registered_host()
|
||||
host = registered_host()
|
||||
representation_id = str(look_representation['_id'])
|
||||
for container in host.ls():
|
||||
if (container['loader'] == "LookLoader" and
|
||||
|
|
|
|||
|
|
@ -11,10 +11,12 @@ try:
|
|||
except Exception:
|
||||
from openpype.lib.python_2_comp import WeakMethod
|
||||
|
||||
import avalon.api
|
||||
import pyblish.api
|
||||
|
||||
from openpype.pipeline import PublishValidationError
|
||||
from openpype.pipeline import (
|
||||
PublishValidationError,
|
||||
registered_host,
|
||||
)
|
||||
from openpype.pipeline.create import CreateContext
|
||||
|
||||
from Qt import QtCore
|
||||
|
|
@ -353,7 +355,7 @@ class PublisherController:
|
|||
"""
|
||||
def __init__(self, dbcon=None, headless=False):
|
||||
self.log = logging.getLogger("PublisherController")
|
||||
self.host = avalon.api.registered_host()
|
||||
self.host = registered_host()
|
||||
self.headless = headless
|
||||
|
||||
self.create_context = CreateContext(
|
||||
|
|
|
|||
|
|
@ -7,8 +7,11 @@ from Qt import QtCore, QtGui
|
|||
import qtawesome
|
||||
from bson.objectid import ObjectId
|
||||
|
||||
from avalon import api, io, schema
|
||||
from openpype.pipeline import HeroVersionType
|
||||
from avalon import io, schema
|
||||
from openpype.pipeline import (
|
||||
HeroVersionType,
|
||||
registered_host,
|
||||
)
|
||||
from openpype.style import get_default_entity_icon_color
|
||||
from openpype.tools.utils.models import TreeModel, Item
|
||||
from openpype.modules import ModulesManager
|
||||
|
|
@ -181,7 +184,7 @@ class InventoryModel(TreeModel):
|
|||
def refresh(self, selected=None, items=None):
|
||||
"""Refresh the model"""
|
||||
|
||||
host = api.registered_host()
|
||||
host = registered_host()
|
||||
if not items: # for debugging or testing, injecting items from outside
|
||||
items = host.ls()
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import uuid
|
|||
|
||||
from Qt import QtCore, QtGui
|
||||
|
||||
from avalon import api
|
||||
from openpype.pipeline import registered_host
|
||||
|
||||
ITEM_ID_ROLE = QtCore.Qt.UserRole + 1
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ class InstanceModel(QtGui.QStandardItemModel):
|
|||
self._instances_by_item_id = {}
|
||||
|
||||
instances = None
|
||||
host = api.registered_host()
|
||||
host = registered_host()
|
||||
list_instances = getattr(host, "list_instances", None)
|
||||
if list_instances:
|
||||
instances = list_instances()
|
||||
|
|
|
|||
|
|
@ -4,9 +4,8 @@ import sys
|
|||
from Qt import QtWidgets, QtCore
|
||||
import qtawesome
|
||||
|
||||
from avalon import api
|
||||
|
||||
from openpype import style
|
||||
from openpype.pipeline import registered_host
|
||||
from openpype.tools.utils import PlaceholderLineEdit
|
||||
from openpype.tools.utils.lib import (
|
||||
iter_model_rows,
|
||||
|
|
@ -106,7 +105,7 @@ class SubsetManagerWindow(QtWidgets.QDialog):
|
|||
self._details_widget.set_details(container, item_id)
|
||||
|
||||
def _on_save(self):
|
||||
host = api.registered_host()
|
||||
host = registered_host()
|
||||
if not hasattr(host, "save_instances"):
|
||||
print("BUG: Host does not have \"save_instances\" method")
|
||||
return
|
||||
|
|
@ -141,7 +140,7 @@ class SubsetManagerWindow(QtWidgets.QDialog):
|
|||
# Prepare menu
|
||||
menu = QtWidgets.QMenu(self)
|
||||
actions = []
|
||||
host = api.registered_host()
|
||||
host = registered_host()
|
||||
if hasattr(host, "remove_instance"):
|
||||
action = QtWidgets.QAction("Remove instance", menu)
|
||||
action.setData(host.remove_instance)
|
||||
|
|
@ -176,7 +175,7 @@ class SubsetManagerWindow(QtWidgets.QDialog):
|
|||
self._details_widget.set_details(None, None)
|
||||
self._model.refresh()
|
||||
|
||||
host = api.registered_host()
|
||||
host = registered_host()
|
||||
dev_mode = os.environ.get("AVALON_DEVELOP_MODE") or ""
|
||||
editable = False
|
||||
if dev_mode.lower() in ("1", "yes", "true", "on"):
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import logging
|
|||
|
||||
from avalon import api
|
||||
|
||||
from openpype.pipeline import registered_host
|
||||
from openpype.tools.utils import qt_app_context
|
||||
from .window import Window
|
||||
|
||||
|
|
@ -47,7 +48,7 @@ def show(root=None, debug=False, parent=None, use_context=True, save=True):
|
|||
except (AttributeError, RuntimeError):
|
||||
pass
|
||||
|
||||
host = api.registered_host()
|
||||
host = registered_host()
|
||||
validate_host_requirements(host)
|
||||
|
||||
if debug:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue