From fd684010a863621f1b9b339f9dc5a9c582998397 Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Tue, 6 Feb 2024 15:02:57 +0100 Subject: [PATCH] use AddonsManager over ModulesManager --- client/ayon_core/addon/base.py | 28 +++++++ client/ayon_core/cli_commands.py | 8 +- client/ayon_core/host/dirmap.py | 4 +- .../hosts/aftereffects/api/launch_logic.py | 4 +- client/ayon_core/hosts/nuke/api/lib.py | 5 +- client/ayon_core/hosts/photoshop/api/lib.py | 4 +- .../hosts/tvpaint/worker/worker_job.py | 6 +- client/ayon_core/lib/applications.py | 76 ++++++++++++------- .../collect_default_deadline_server.py | 2 +- .../royalrender/royal_render_module.py | 2 +- .../launch_hooks/post_start_timer.py | 4 +- .../plugins/publish/start_timer.py | 4 +- .../plugins/publish/stop_timer.py | 4 +- client/ayon_core/pipeline/anatomy.py | 6 +- client/ayon_core/pipeline/context_tools.py | 34 ++++----- .../plugins/load/delete_old_versions.py | 8 +- .../plugins/publish/collect_farm_target.py | 12 +-- .../plugins/publish/collect_modules.py | 16 ++-- client/ayon_core/plugins/publish/integrate.py | 8 +- client/ayon_core/settings/ayon_settings.py | 2 +- .../tools/loader/models/site_sync.py | 4 +- .../tools/push_to_project/models/integrate.py | 6 +- .../tools/sceneinventory/models/site_sync.py | 6 +- client/ayon_core/tools/tray/pype_tray.py | 27 ++++--- 24 files changed, 163 insertions(+), 117 deletions(-) diff --git a/client/ayon_core/addon/base.py b/client/ayon_core/addon/base.py index 2c7c4f11c6..3b7bf70c56 100644 --- a/client/ayon_core/addon/base.py +++ b/client/ayon_core/addon/base.py @@ -1184,26 +1184,54 @@ class AddonsManager: # DEPRECATED - Module compatibility @property def modules(self): + self.log.warning( + "DEPRECATION WARNING: Used deprecated property" + " 'modules' please use 'addons' instead." + ) return self.addons @property def modules_by_id(self): + self.log.warning( + "DEPRECATION WARNING: Used deprecated property" + " 'modules_by_id' please use 'addons_by_id' instead." + ) return self.addons_by_id @property def modules_by_name(self): + self.log.warning( + "DEPRECATION WARNING: Used deprecated property" + " 'modules_by_name' please use 'addons_by_name' instead." + ) return self.addons_by_name def get_enabled_module(self, *args, **kwargs): + self.log.warning( + "DEPRECATION WARNING: Used deprecated method" + " 'get_enabled_module' please use 'get_enabled_addon' instead." + ) return self.get_enabled_addon(*args, **kwargs) def initialize_modules(self): + self.log.warning( + "DEPRECATION WARNING: Used deprecated method" + " 'initialize_modules' please use 'initialize_addons' instead." + ) self.initialize_addons() def get_enabled_modules(self): + self.log.warning( + "DEPRECATION WARNING: Used deprecated method" + " 'get_enabled_modules' please use 'get_enabled_addons' instead." + ) return self.get_enabled_addons() def get_host_module(self, host_name): + self.log.warning( + "DEPRECATION WARNING: Used deprecated method" + " 'get_host_module' please use 'get_host_addon' instead." + ) return self.get_host_addon(host_name) diff --git a/client/ayon_core/cli_commands.py b/client/ayon_core/cli_commands.py index cabffae5e6..08a55468a0 100644 --- a/client/ayon_core/cli_commands.py +++ b/client/ayon_core/cli_commands.py @@ -24,9 +24,9 @@ class Commands: """Modules/Addons can add their cli commands dynamically.""" from ayon_core.lib import Logger - from ayon_core.modules import ModulesManager + from ayon_core.addon import AddonsManager - manager = ModulesManager() + manager = AddonsManager() log = Logger.get_logger("CLI-AddModules") for addon in manager.modules: try: @@ -61,7 +61,7 @@ class Commands: get_app_environments_for_context, LaunchTypes, ) - from ayon_core.modules import ModulesManager + from ayon_core.addon import AddonsManager from ayon_core.pipeline import ( install_openpype_plugins, get_global_context, @@ -77,7 +77,7 @@ class Commands: install_openpype_plugins() - manager = ModulesManager() + manager = AddonsManager() publish_paths = manager.collect_plugin_paths()["publish"] diff --git a/client/ayon_core/host/dirmap.py b/client/ayon_core/host/dirmap.py index 1f8fddadcf..cecd689a4c 100644 --- a/client/ayon_core/host/dirmap.py +++ b/client/ayon_core/host/dirmap.py @@ -13,7 +13,7 @@ import platform import six from ayon_core.lib import Logger -from ayon_core.modules import ModulesManager +from ayon_core.addon import AddonsManager from ayon_core.settings import get_project_settings from ayon_core.settings.lib import get_site_local_overrides @@ -50,7 +50,7 @@ class HostDirmap(object): def sync_module(self): if not self._sync_module_discovered: self._sync_module_discovered = True - manager = ModulesManager() + manager = AddonsManager() self._sync_module = manager.get("sync_server") return self._sync_module diff --git a/client/ayon_core/hosts/aftereffects/api/launch_logic.py b/client/ayon_core/hosts/aftereffects/api/launch_logic.py index 1560daf162..5248eb20a7 100644 --- a/client/ayon_core/hosts/aftereffects/api/launch_logic.py +++ b/client/ayon_core/hosts/aftereffects/api/launch_logic.py @@ -18,7 +18,7 @@ from qtpy import QtCore from ayon_core.lib import Logger from ayon_core.tests.lib import is_in_tests from ayon_core.pipeline import install_host, legacy_io -from ayon_core.modules import ModulesManager +from ayon_core.addon import AddonsManager from ayon_core.tools.utils import host_tools, get_openpype_qt_app from ayon_core.tools.adobe_webserver.app import WebServerTool @@ -50,7 +50,7 @@ def main(*subprocess_args): launcher.start() if os.environ.get("HEADLESS_PUBLISH"): - manager = ModulesManager() + manager = AddonsManager() webpublisher_addon = manager["webpublisher"] launcher.execute_in_main_thread( diff --git a/client/ayon_core/hosts/nuke/api/lib.py b/client/ayon_core/hosts/nuke/api/lib.py index 1b62702964..eb85c14fdb 100644 --- a/client/ayon_core/hosts/nuke/api/lib.py +++ b/client/ayon_core/hosts/nuke/api/lib.py @@ -37,7 +37,7 @@ from ayon_core.settings import ( get_project_settings, get_current_project_settings, ) -from ayon_core.modules import ModulesManager +from ayon_core.addon import AddonsManager from ayon_core.pipeline.template_data import get_template_data_with_names from ayon_core.pipeline import ( discover_legacy_creator_plugins, @@ -3217,8 +3217,7 @@ class DirmapCache: def sync_module(cls): if not cls._sync_module_discovered: cls._sync_module_discovered = True - cls._sync_module = ModulesManager().modules_by_name.get( - "sync_server") + cls._sync_module = AddonsManager().get("sync_server") return cls._sync_module @classmethod diff --git a/client/ayon_core/hosts/photoshop/api/lib.py b/client/ayon_core/hosts/photoshop/api/lib.py index 1343837c01..a5dc0c5d79 100644 --- a/client/ayon_core/hosts/photoshop/api/lib.py +++ b/client/ayon_core/hosts/photoshop/api/lib.py @@ -4,7 +4,7 @@ import contextlib import traceback from ayon_core.lib import env_value_to_bool, Logger -from ayon_core.modules import ModulesManager +from ayon_core.addon import AddonsManager from ayon_core.pipeline import install_host from ayon_core.tools.utils import host_tools from ayon_core.tools.utils import get_openpype_qt_app @@ -36,7 +36,7 @@ def main(*subprocess_args): launcher.start() if env_value_to_bool("HEADLESS_PUBLISH"): - manager = ModulesManager() + manager = AddonsManager() webpublisher_addon = manager["webpublisher"] launcher.execute_in_main_thread( webpublisher_addon.headless_publish, diff --git a/client/ayon_core/hosts/tvpaint/worker/worker_job.py b/client/ayon_core/hosts/tvpaint/worker/worker_job.py index c5240dbafb..f111ed369a 100644 --- a/client/ayon_core/hosts/tvpaint/worker/worker_job.py +++ b/client/ayon_core/hosts/tvpaint/worker/worker_job.py @@ -10,7 +10,7 @@ from abc import ABCMeta, abstractmethod, abstractproperty import six from ayon_core.lib import Logger -from ayon_core.modules import ModulesManager +from ayon_core.addons import AddonsManger TMP_FILE_PREFIX = "opw_tvp_" @@ -309,8 +309,8 @@ class TVPaintCommands: self._commands = [] self._command_classes_by_name = None if job_queue_module is None: - manager = ModulesManager() - job_queue_module = manager.modules_by_name["job_queue"] + manager = AddonsManger() + job_queue_module = manager["job_queue"] self._job_queue_module = job_queue_module self._workfile = self._prepare_workfile(workfile) diff --git a/client/ayon_core/lib/applications.py b/client/ayon_core/lib/applications.py index 959e118641..7a2e787e47 100644 --- a/client/ayon_core/lib/applications.py +++ b/client/ayon_core/lib/applications.py @@ -868,9 +868,17 @@ class LaunchHook: def app_name(self): return getattr(self.application, "full_name", None) + @property + def addons_manager(self): + return getattr(self.launch_context, "addons_manager", None) + @property def modules_manager(self): - return getattr(self.launch_context, "modules_manager", None) + """ + Deprecated: + Use 'addons_wrapper' instead. + """ + return self.addons_manager def validate(self): """Optional validation of launch hook on initialization. @@ -950,12 +958,12 @@ class ApplicationLaunchContext: launch_type=None, **data ): - from ayon_core.modules import ModulesManager + from ayon_core.addon import AddonsManager # Application object self.application = application - self.modules_manager = ModulesManager() + self.addons_manager = AddonsManager() # Logger logger_name = "{}-{}".format(self.__class__.__name__, @@ -1042,6 +1050,15 @@ class ApplicationLaunchContext: ) self.kwargs["env"] = value + @property + def modules_manager(self): + """ + Deprecated: + Use 'addons_manager' instead. + + """ + return self.addons_manager + def _collect_addons_launch_hook_paths(self): """Helper to collect application launch hooks from addons. @@ -1055,7 +1072,7 @@ class ApplicationLaunchContext: expected_types = (list, tuple, set) output = [] - for module in self.modules_manager.get_enabled_modules(): + for module in self.addons_manager.get_enabled_addons(): # Skip module if does not have implemented 'get_launch_hook_paths' func = getattr(module, "get_launch_hook_paths", None) if func is None: @@ -1114,7 +1131,7 @@ class ApplicationLaunchContext: # If host requires launch hooks and is module then launch hooks # should be collected using 'collect_launch_hook_paths' # - module have to implement 'get_launch_hook_paths' - host_module = self.modules_manager.get_host_module(self.host_name) + host_module = self.addons_manager.get_host_addon(self.host_name) if not host_module: hooks_dirs.append(os.path.join( AYON_CORE_ROOT, "hosts", self.host_name, "hooks" @@ -1442,7 +1459,7 @@ def get_app_environments_for_context( env_group=None, launch_type=None, env=None, - modules_manager=None + addons_manager=None ): """Prepare environment variables by context. Args: @@ -1457,7 +1474,7 @@ def get_app_environments_for_context( executed. env (Optional[dict[str, str]]): Initial environment variables. `os.environ` is used when not passed. - modules_manager (Optional[ModulesManager]): Initialized modules + addons_manager (Optional[AddonsManager]): Initialized modules manager. Returns: @@ -1474,7 +1491,8 @@ def get_app_environments_for_context( env_group=env_group, launch_type=launch_type, env=env, - modules_manager=modules_manager, + addons_manager=addons_manager, + modules_manager=addons_manager, ) context.run_prelaunch_hooks() return context.env @@ -1492,11 +1510,11 @@ def _merge_env(env, current_env): return result -def _add_python_version_paths(app, env, logger, modules_manager): +def _add_python_version_paths(app, env, logger, addons_manager): """Add vendor packages specific for a Python version.""" - for module in modules_manager.get_enabled_modules(): - module.modify_application_launch_arguments(app, env) + for addon in addons_manager.get_enabled_addons(): + addon.modify_application_launch_arguments(app, env) # Skip adding if host name is not set if not app.host_name: @@ -1529,7 +1547,7 @@ def _add_python_version_paths(app, env, logger, modules_manager): def prepare_app_environments( - data, env_group=None, implementation_envs=True, modules_manager=None + data, env_group=None, implementation_envs=True, addons_manager=None ): """Modify launch environments based on launched app and context. @@ -1543,12 +1561,12 @@ def prepare_app_environments( log = data["log"] source_env = data["env"].copy() - if modules_manager is None: - from ayon_core.modules import ModulesManager + if addons_manager is None: + from ayon_core.addon import AddonsManager - modules_manager = ModulesManager() + addons_manager = AddonsManager() - _add_python_version_paths(app, source_env, log, modules_manager) + _add_python_version_paths(app, source_env, log, addons_manager) # Use environments from local settings filtered_local_envs = {} @@ -1628,14 +1646,14 @@ def prepare_app_environments( final_env = None # Add host specific environments if app.host_name and implementation_envs: - host_module = modules_manager.get_host_module(app.host_name) - if not host_module: + host_addon = addons_manager.get_host_addon(app.host_name) + if not host_addon: module = __import__("ayon_core.hosts", fromlist=[app.host_name]) host_module = getattr(module, app.host_name, None) add_implementation_envs = None - if host_module: + if host_addon: add_implementation_envs = getattr( - host_module, "add_implementation_envs", None + host_addon, "add_implementation_envs", None ) if add_implementation_envs: # Function may only modify passed dict without returning value @@ -1690,7 +1708,7 @@ def apply_project_environments_value( return env -def prepare_context_environments(data, env_group=None, modules_manager=None): +def prepare_context_environments(data, env_group=None, addons_manager=None): """Modify launch environments with context data for launched host. Args: @@ -1796,10 +1814,10 @@ def prepare_context_environments(data, env_group=None, modules_manager=None): data["env"]["AVALON_WORKDIR"] = workdir - _prepare_last_workfile(data, workdir, modules_manager) + _prepare_last_workfile(data, workdir, addons_manager) -def _prepare_last_workfile(data, workdir, modules_manager): +def _prepare_last_workfile(data, workdir, addons_manager): """last workfile workflow preparation. Function check if should care about last workfile workflow and tries @@ -1815,11 +1833,11 @@ def _prepare_last_workfile(data, workdir, modules_manager): workdir (str): Path to folder where workfiles should be stored. """ - from ayon_core.modules import ModulesManager + from ayon_core.addon import AddonsManager from ayon_core.pipeline import HOST_WORKFILE_EXTENSIONS - if not modules_manager: - modules_manager = ModulesManager() + if not addons_manager: + addons_manager = AddonsManager() log = data["log"] @@ -1868,9 +1886,9 @@ def _prepare_last_workfile(data, workdir, modules_manager): # Last workfile path last_workfile_path = data.get("last_workfile_path") or "" if not last_workfile_path: - host_module = modules_manager.get_host_module(app.host_name) - if host_module: - extensions = host_module.get_workfile_extensions() + host_addon = addons_manager.get_host_addon(app.host_name) + if host_addon: + extensions = host_addon.get_workfile_extensions() else: extensions = HOST_WORKFILE_EXTENSIONS.get(app.host_name) diff --git a/client/ayon_core/modules/deadline/plugins/publish/collect_default_deadline_server.py b/client/ayon_core/modules/deadline/plugins/publish/collect_default_deadline_server.py index c054b90af5..4c4cdb8c26 100644 --- a/client/ayon_core/modules/deadline/plugins/publish/collect_default_deadline_server.py +++ b/client/ayon_core/modules/deadline/plugins/publish/collect_default_deadline_server.py @@ -25,7 +25,7 @@ class CollectDefaultDeadlineServer(pyblish.api.ContextPlugin): def process(self, context): try: - deadline_module = context.data.get("openPypeModules")["deadline"] + deadline_module = context.data["ayonAddonsManger"]["deadline"] except AttributeError: self.log.error("Cannot get OpenPype Deadline module.") raise AssertionError("OpenPype Deadline module not found.") diff --git a/client/ayon_core/modules/royalrender/royal_render_module.py b/client/ayon_core/modules/royalrender/royal_render_module.py index ff0052925d..66b09832d8 100644 --- a/client/ayon_core/modules/royalrender/royal_render_module.py +++ b/client/ayon_core/modules/royalrender/royal_render_module.py @@ -19,7 +19,7 @@ class RoyalRenderModule(OpenPypeModule, IPluginPaths): return self._api def __init__(self, manager, settings): - # type: (ayon_core.modules.base.ModulesManager, dict) -> None + # type: (ayon_core.addon.AddonsManager, dict) -> None self.rr_paths = {} self._api = None self.settings = settings diff --git a/client/ayon_core/modules/timers_manager/launch_hooks/post_start_timer.py b/client/ayon_core/modules/timers_manager/launch_hooks/post_start_timer.py index a50860089f..d8710a9b26 100644 --- a/client/ayon_core/modules/timers_manager/launch_hooks/post_start_timer.py +++ b/client/ayon_core/modules/timers_manager/launch_hooks/post_start_timer.py @@ -31,9 +31,7 @@ class PostStartTimerHook(PostLaunchHook): )) return - timers_manager = self.modules_manager.modules_by_name.get( - "timers_manager" - ) + timers_manager = self.addons_manager.get("timers_manager") if not timers_manager or not timers_manager.enabled: self.log.info(( "Skipping starting timer because" diff --git a/client/ayon_core/modules/timers_manager/plugins/publish/start_timer.py b/client/ayon_core/modules/timers_manager/plugins/publish/start_timer.py index 19a67292f5..46046d73ab 100644 --- a/client/ayon_core/modules/timers_manager/plugins/publish/start_timer.py +++ b/client/ayon_core/modules/timers_manager/plugins/publish/start_timer.py @@ -1,7 +1,7 @@ """ Requires: context -> system_settings - context -> openPypeModules + context -> ayonAddonsManger """ import pyblish.api @@ -13,7 +13,7 @@ class StartTimer(pyblish.api.ContextPlugin): hosts = ["*"] def process(self, context): - timers_manager = context.data["openPypeModules"]["timers_manager"] + timers_manager = context.data["ayonAddonsManger"]["timers_manager"] if not timers_manager.enabled: self.log.debug("TimersManager is disabled") return diff --git a/client/ayon_core/modules/timers_manager/plugins/publish/stop_timer.py b/client/ayon_core/modules/timers_manager/plugins/publish/stop_timer.py index a8674ff2ca..755dccbff6 100644 --- a/client/ayon_core/modules/timers_manager/plugins/publish/stop_timer.py +++ b/client/ayon_core/modules/timers_manager/plugins/publish/stop_timer.py @@ -1,7 +1,7 @@ """ Requires: context -> system_settings - context -> openPypeModules + context -> ayonAddonsManger """ @@ -14,7 +14,7 @@ class StopTimer(pyblish.api.ContextPlugin): hosts = ["*"] def process(self, context): - timers_manager = context.data["openPypeModules"]["timers_manager"] + timers_manager = context.data["ayonAddonsManger"]["timers_manager"] if not timers_manager.enabled: self.log.debug("TimersManager is disabled") return diff --git a/client/ayon_core/pipeline/anatomy.py b/client/ayon_core/pipeline/anatomy.py index 3c98727fdf..777158edd1 100644 --- a/client/ayon_core/pipeline/anatomy.py +++ b/client/ayon_core/pipeline/anatomy.py @@ -20,7 +20,7 @@ from ayon_core.lib.path_templates import ( TemplatesDict, FormatObject, ) -from ayon_core.modules import ModulesManager +from ayon_core.addon import AddonsManager log = Logger.get_logger(__name__) @@ -446,9 +446,9 @@ class Anatomy(BaseAnatomy): @classmethod def get_sync_server_addon(cls): if cls._sync_server_addon_cache.is_outdated: - manager = ModulesManager() + manager = AddonsManager() cls._sync_server_addon_cache.update_data( - manager.get_enabled_module("sync_server") + manager.get_enabled_addon("sync_server") ) return cls._sync_server_addon_cache.data diff --git a/client/ayon_core/pipeline/context_tools.py b/client/ayon_core/pipeline/context_tools.py index f2737f0bc2..07ea8d318b 100644 --- a/client/ayon_core/pipeline/context_tools.py +++ b/client/ayon_core/pipeline/context_tools.py @@ -21,7 +21,7 @@ from ayon_core.client import ( get_ayon_server_api_connection, ) from ayon_core.lib.events import emit_event -from ayon_core.modules import load_modules, ModulesManager +from ayon_core.addon import load_addons, AddonsManager from ayon_core.settings import get_project_settings from ayon_core.tests.lib import is_in_tests @@ -48,7 +48,7 @@ _registered_root = {"_": {}} _registered_host = {"_": None} # Keep modules manager (and it's modules) in memory # - that gives option to register modules' callbacks -_modules_manager = None +_addons_manager = None log = logging.getLogger(__name__) @@ -60,7 +60,7 @@ LOAD_PATH = os.path.join(PLUGINS_DIR, "load") INVENTORY_PATH = os.path.join(PLUGINS_DIR, "inventory") -def _get_modules_manager(): +def _get_addons_manager(): """Get or create modules manager for host installation. This is not meant for public usage. Reason is to keep modules @@ -68,13 +68,13 @@ def _get_modules_manager(): need any. Returns: - ModulesManager: Manager wrapping discovered modules. + AddonsManager: Manager wrapping discovered modules. """ - global _modules_manager - if _modules_manager is None: - _modules_manager = ModulesManager() - return _modules_manager + global _addons_manager + if _addons_manager is None: + _addons_manager = AddonsManager() + return _addons_manager def register_root(path): @@ -117,7 +117,7 @@ def install_host(host): get_ayon_server_api_connection() legacy_io.install() - modules_manager = _get_modules_manager() + addons_manager = _get_addons_manager() missing = list() for key in ("AVALON_PROJECT", "AVALON_ASSET"): @@ -162,15 +162,15 @@ def install_host(host): host_name = os.environ.get("AVALON_APP") # Give option to handle host installation - for module in modules_manager.get_enabled_modules(): - module.on_host_install(host, host_name, project_name) + for addon in addons_manager.get_enabled_addons(): + addon.on_host_install(host, host_name, project_name) install_openpype_plugins(project_name, host_name) def install_openpype_plugins(project_name=None, host_name=None): # Make sure modules are loaded - load_modules() + load_addons() log.info("Registering global plug-ins..") pyblish.api.register_plugin_path(PUBLISH_PATH) @@ -181,23 +181,23 @@ def install_openpype_plugins(project_name=None, host_name=None): if host_name is None: host_name = os.environ.get("AVALON_APP") - modules_manager = _get_modules_manager() - publish_plugin_dirs = modules_manager.collect_publish_plugin_paths( + addons_manager = _get_addons_manager() + publish_plugin_dirs = addons_manager.collect_publish_plugin_paths( host_name) for path in publish_plugin_dirs: pyblish.api.register_plugin_path(path) - create_plugin_paths = modules_manager.collect_create_plugin_paths( + create_plugin_paths = addons_manager.collect_create_plugin_paths( host_name) for path in create_plugin_paths: register_creator_plugin_path(path) - load_plugin_paths = modules_manager.collect_load_plugin_paths( + load_plugin_paths = addons_manager.collect_load_plugin_paths( host_name) for path in load_plugin_paths: register_loader_plugin_path(path) - inventory_action_paths = modules_manager.collect_inventory_action_paths( + inventory_action_paths = addons_manager.collect_inventory_action_paths( host_name) for path in inventory_action_paths: register_inventory_action_path(path) diff --git a/client/ayon_core/plugins/load/delete_old_versions.py b/client/ayon_core/plugins/load/delete_old_versions.py index 834e9f03fc..05df8b3cc1 100644 --- a/client/ayon_core/plugins/load/delete_old_versions.py +++ b/client/ayon_core/plugins/load/delete_old_versions.py @@ -9,7 +9,7 @@ from qtpy import QtWidgets, QtCore from ayon_core import style from ayon_core.client import get_versions, get_representations -from ayon_core.modules import ModulesManager +from ayon_core.addon import AddonsManager from ayon_core.lib import format_file_size from ayon_core.pipeline import load, AvalonMongoDB, Anatomy from ayon_core.pipeline.load import ( @@ -391,9 +391,9 @@ class DeleteOldVersions(load.SubsetLoaderPlugin): return # Check if ftrack module is enabled - modules_manager = ModulesManager() - ftrack_module = modules_manager.modules_by_name.get("ftrack") - if not ftrack_module or not ftrack_module.enabled: + addons_manager = AddonsManager() + ftrack_addon = addons_manager.get("ftrack") + if not ftrack_addon or not ftrack_addon.enabled: return import ftrack_api diff --git a/client/ayon_core/plugins/publish/collect_farm_target.py b/client/ayon_core/plugins/publish/collect_farm_target.py index 2f77c823d7..d169b3275a 100644 --- a/client/ayon_core/plugins/publish/collect_farm_target.py +++ b/client/ayon_core/plugins/publish/collect_farm_target.py @@ -17,16 +17,16 @@ class CollectFarmTarget(pyblish.api.InstancePlugin): context = instance.context farm_name = "" - op_modules = context.data.get("openPypeModules") + addons_manager = context.data.get("ayonAddonsManger") for farm_renderer in ["deadline", "royalrender"]: - op_module = op_modules.get(farm_renderer, False) + addon = addons_manager.get(farm_renderer, False) - if op_module and op_module.enabled: - farm_name = farm_renderer - elif not op_module: - self.log.error("Cannot get OpenPype {0} module.".format( + if not addon: + self.log.error("Cannot find AYON addon '{0}'.".format( farm_renderer)) + elif addon.enabled: + farm_name = farm_renderer if farm_name: self.log.debug("Collected render target: {0}".format(farm_name)) diff --git a/client/ayon_core/plugins/publish/collect_modules.py b/client/ayon_core/plugins/publish/collect_modules.py index 6cb7792ad5..6ed1ffefb3 100644 --- a/client/ayon_core/plugins/publish/collect_modules.py +++ b/client/ayon_core/plugins/publish/collect_modules.py @@ -1,15 +1,19 @@ # -*- coding: utf-8 -*- -"""Collect OpenPype modules.""" -from ayon_core.modules import ModulesManager +"""Collect AYON addons.""" import pyblish.api +from ayon_core.modules import AddonsManager + class CollectModules(pyblish.api.ContextPlugin): - """Collect OpenPype modules.""" + """Collect AYON addons.""" order = pyblish.api.CollectorOrder - 0.5 - label = "OpenPype Modules" + label = "AYON Addons" def process(self, context): - manager = ModulesManager() - context.data["openPypeModules"] = manager.modules_by_name + manager = AddonsManager() + context.data["ayonAddonsManger"] = manager + context.data["ayonAddons"] = manager.addons_by_name + # Backwards compatibility - remove + context.data["openPypeModules"] = manager.addons_by_name diff --git a/client/ayon_core/plugins/publish/integrate.py b/client/ayon_core/plugins/publish/integrate.py index 713207505c..88fa533da6 100644 --- a/client/ayon_core/plugins/publish/integrate.py +++ b/client/ayon_core/plugins/publish/integrate.py @@ -322,15 +322,15 @@ class IntegrateAsset(pyblish.api.InstancePlugin): self.log.debug("Retrieving Representation Site Sync information ...") # Get the accessible sites for Site Sync - modules_by_name = instance.context.data["openPypeModules"] - sync_server_module = modules_by_name.get("sync_server") - if sync_server_module is None: + addons_manager = instance.context.data["ayonAddonsManger"] + sync_server_addon = addons_manager.get("sync_server") + if sync_server_addon is None: sites = [{ "name": "studio", "created_dt": datetime.datetime.now() }] else: - sites = sync_server_module.compute_resource_sync_sites( + sites = sync_server_addon.compute_resource_sync_sites( project_name=instance.data["projectEntity"]["name"] ) self.log.debug("Sync Server Sites: {}".format(sites)) diff --git a/client/ayon_core/settings/ayon_settings.py b/client/ayon_core/settings/ayon_settings.py index f0975a7896..ed1199d517 100644 --- a/client/ayon_core/settings/ayon_settings.py +++ b/client/ayon_core/settings/ayon_settings.py @@ -269,7 +269,7 @@ def _convert_modules_system( output[key] = value # Make sure addons have access to settings in initialization - # - ModulesManager passes only modules settings into initialization + # - AddonsManager passes only modules settings into initialization if key not in modules_settings: modules_settings[key] = value diff --git a/client/ayon_core/tools/loader/models/site_sync.py b/client/ayon_core/tools/loader/models/site_sync.py index 9e9fdc5313..e6158ea280 100644 --- a/client/ayon_core/tools/loader/models/site_sync.py +++ b/client/ayon_core/tools/loader/models/site_sync.py @@ -3,7 +3,7 @@ import collections from ayon_core.lib import Logger from ayon_core.client.entities import get_representations from ayon_core.client import get_linked_representation_id -from ayon_core.modules import ModulesManager +from ayon_core.addon import AddonsManager from ayon_core.tools.ayon_utils.models import NestedCacheItem from ayon_core.tools.loader.abstract import ActionItem @@ -56,7 +56,7 @@ class SiteSyncModel: lifetime=self.status_lifetime ) - manager = ModulesManager() + manager = AddonsManager() self._site_sync_addon = manager.get("sync_server") def reset(self): diff --git a/client/ayon_core/tools/push_to_project/models/integrate.py b/client/ayon_core/tools/push_to_project/models/integrate.py index 4f23f97b98..361b556b1e 100644 --- a/client/ayon_core/tools/push_to_project/models/integrate.py +++ b/client/ayon_core/tools/push_to_project/models/integrate.py @@ -30,7 +30,7 @@ from ayon_core.client.operations import ( prepare_version_update_data, prepare_representation_update_data, ) -from ayon_core.modules import ModulesManager +from ayon_core.addon import AddonsManager from ayon_core.lib import ( StringTemplate, get_openpype_username, @@ -1056,8 +1056,8 @@ class ProjectPushItemProcess: path_template, existing_repres_by_low_name ): - modules_manager = ModulesManager() - sync_server_module = modules_manager.get("sync_server") + addons_manager = AddonsManager() + sync_server_module = addons_manager.get("sync_server") if sync_server_module is None or not sync_server_module.enabled: sites = [{ "name": "studio", diff --git a/client/ayon_core/tools/sceneinventory/models/site_sync.py b/client/ayon_core/tools/sceneinventory/models/site_sync.py index 0b6dffb909..c7bc0b756d 100644 --- a/client/ayon_core/tools/sceneinventory/models/site_sync.py +++ b/client/ayon_core/tools/sceneinventory/models/site_sync.py @@ -1,5 +1,5 @@ from ayon_core.client import get_representations -from ayon_core.modules import ModulesManager +from ayon_core.addon import AddonsManager NOT_SET = object() @@ -123,8 +123,8 @@ class SiteSyncModel: def _cache_sync_server_module(self): if self._sync_server_module is not NOT_SET: return self._sync_server_module - manager = ModulesManager() - site_sync = manager.modules_by_name.get("sync_server") + manager = AddonsManager() + site_sync = manager.get("sync_server") sync_enabled = site_sync is not None and site_sync.enabled self._sync_server_module = site_sync self._sync_server_enabled = sync_enabled diff --git a/client/ayon_core/tools/tray/pype_tray.py b/client/ayon_core/tools/tray/pype_tray.py index 8e6d397ff9..fe976e464c 100644 --- a/client/ayon_core/tools/tray/pype_tray.py +++ b/client/ayon_core/tools/tray/pype_tray.py @@ -68,7 +68,7 @@ class PixmapLabel(QtWidgets.QLabel): class TrayManager: """Cares about context of application. - Load submenus, actions, separators and modules into tray's context. + Load submenus, actions, separators and addons into tray's context. """ def __init__(self, tray_widget, main_window): self.tray_widget = tray_widget @@ -79,7 +79,6 @@ class TrayManager: self.log = Logger.get_logger(self.__class__.__name__) system_settings = get_system_settings() - self.module_settings = system_settings["modules"] version_check_interval = system_settings["general"].get( "version_check_interval" @@ -132,7 +131,7 @@ class TrayManager: self._execution_in_progress = False - def initialize_modules(self): + def initialize_addons(self): """Add addons to tray.""" self._addons_manager.initialize(self, self.tray_widget.menu) @@ -154,7 +153,7 @@ class TrayManager: exit_action.triggered.connect(self.tray_widget.exit) self.tray_widget.menu.addAction(exit_action) - # Tell each module which modules were imported + # Tell each addon which addons were imported self._addons_manager.start_addons() # Print time report @@ -321,7 +320,7 @@ class SystemTrayIcon(QtWidgets.QSystemTrayIcon): self.menu = QtWidgets.QMenu() self.menu.setStyleSheet(style.load_stylesheet()) - # Set modules + # Set addons self.tray_man = TrayManager(self, self.parent) # Add menu to Context of SystemTrayIcon @@ -345,16 +344,16 @@ class SystemTrayIcon(QtWidgets.QSystemTrayIcon): self._doubleclick = False self._click_pos = None - self._initializing_modules = False + self._initializing_addons = False @property - def initializing_modules(self): - return self._initializing_modules + def initializing_addons(self): + return self._initializing_addons - def initialize_modules(self): - self._initializing_modules = True - self.tray_man.initialize_modules() - self._initializing_modules = False + def initialize_addons(self): + self._initializing_addons = True + self.tray_man.initialize_addons() + self._initializing_addons = False def _click_timer_timeout(self): self._click_timer.stop() @@ -432,9 +431,9 @@ class PypeTrayStarter(QtCore.QObject): # Second processing of events to make sure splash is painted QtWidgets.QApplication.processEvents() self._timer_counter += 1 - self._tray_widget.initialize_modules() + self._tray_widget.initialize_addons() - elif not self._tray_widget.initializing_modules: + elif not self._tray_widget.initializing_addons: splash = self._get_splash() splash.hide() self._start_timer.stop()