Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use AYONAddon base class #22

Merged
merged 5 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions client/ayon_core/addon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ AYON addons should contain separated logic of specific kind of implementation, s
- addon must implement `get_plugin_paths` which must return dictionary with possible keys `"publish"`, `"load"`, `"create"` or `"actions"`
- each key may contain list or string with a path to directory with plugins

## ITrayModule
## ITrayAddon
- addon has more logic when used in a tray
- it is possible that addon can be used only in the tray
- abstract methods
Expand All @@ -46,7 +46,7 @@ AYON addons should contain separated logic of specific kind of implementation, s
- if addon has logic only in tray or for both then should be checking for `tray_initialized` attribute to decide how should handle situations

### ITrayService
- inherits from `ITrayModule` and implements `tray_menu` method for you
- inherits from `ITrayAddon` and implements `tray_menu` method for you
- adds action to submenu "Services" in tray widget menu with icon and label
- abstract attribute `label`
- label shown in menu
Expand All @@ -57,7 +57,7 @@ AYON addons should contain separated logic of specific kind of implementation, s
- these states must be set by addon itself `set_service_running` is default state on initialization

### ITrayAction
- inherits from `ITrayModule` and implements `tray_menu` method for you
- inherits from `ITrayAddon` and implements `tray_menu` method for you
- adds action to tray widget menu with label
- abstract attribute `label`
- label shown in menu
Expand Down Expand Up @@ -89,4 +89,4 @@ AYON addons should contain separated logic of specific kind of implementation, s

### TrayAddonsManager
- inherits from `AddonsManager`
- has specific implementation for Pype Tray tool and handle `ITrayModule` methods
- has specific implementation for Pype Tray tool and handle `ITrayAddon` methods
6 changes: 3 additions & 3 deletions client/ayon_core/addon/click_wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
Before
```python
import click
from ayon_core.modules import AYONAddon
from ayon_core.addon import AYONAddon


class ExampleAddon(AYONAddon):
Expand All @@ -40,7 +40,7 @@ def mycommand(arg1, arg2):
Now
```
from ayon_core import click_wrap
from ayon_core.modules import AYONAddon
from ayon_core.addon import AYONAddon


class ExampleAddon(AYONAddon):
Expand Down Expand Up @@ -72,7 +72,7 @@ def mycommand(arg1, arg2):
Example:
```python
from ayon_core import click_wrap
from ayon_core.modules import AYONAddon
from ayon_core.addon import AYONAddon


class ExampleAddon(AYONAddon):
Expand Down
7 changes: 2 additions & 5 deletions client/ayon_core/hosts/aftereffects/addon.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
from ayon_core.modules import OpenPypeModule, IHostAddon
from ayon_core.addon import AYONAddon, IHostAddon


class AfterEffectsAddon(OpenPypeModule, IHostAddon):
class AfterEffectsAddon(AYONAddon, IHostAddon):
name = "aftereffects"
host_name = "aftereffects"

def initialize(self, module_settings):
self.enabled = True

def add_implementation_envs(self, env, _app):
"""Modify environments to contain all required for implementation."""
defaults = {
Expand Down
7 changes: 2 additions & 5 deletions client/ayon_core/hosts/blender/addon.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import os
from ayon_core.modules import OpenPypeModule, IHostAddon
from ayon_core.addon import AYONAddon, IHostAddon

BLENDER_ROOT_DIR = os.path.dirname(os.path.abspath(__file__))


class BlenderAddon(OpenPypeModule, IHostAddon):
class BlenderAddon(AYONAddon, IHostAddon):
name = "blender"
host_name = "blender"

def initialize(self, module_settings):
self.enabled = True

def add_implementation_envs(self, env, _app):
"""Modify environments to contain all required for implementation."""
# Prepare path to implementation script
Expand Down
7 changes: 2 additions & 5 deletions client/ayon_core/hosts/celaction/addon.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import os
from ayon_core.modules import OpenPypeModule, IHostAddon
from ayon_core.addon import AYONAddon, IHostAddon

CELACTION_ROOT_DIR = os.path.dirname(os.path.abspath(__file__))


class CelactionAddon(OpenPypeModule, IHostAddon):
class CelactionAddon(AYONAddon, IHostAddon):
name = "celaction"
host_name = "celaction"

def initialize(self, module_settings):
self.enabled = True

def get_launch_hook_paths(self, app):
if app.host_name != self.host_name:
return []
Expand Down
7 changes: 2 additions & 5 deletions client/ayon_core/hosts/flame/addon.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import os
from ayon_core.modules import OpenPypeModule, IHostAddon
from ayon_core.addon import AYONAddon, IHostAddon

HOST_DIR = os.path.dirname(os.path.abspath(__file__))


class FlameAddon(OpenPypeModule, IHostAddon):
class FlameAddon(AYONAddon, IHostAddon):
name = "flame"
host_name = "flame"

def initialize(self, module_settings):
self.enabled = True

def add_implementation_envs(self, env, _app):
# Add requirements to DL_PYTHON_HOOK_PATH
env["DL_PYTHON_HOOK_PATH"] = os.path.join(HOST_DIR, "startup")
Expand Down
7 changes: 2 additions & 5 deletions client/ayon_core/hosts/fusion/addon.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import re
from ayon_core.modules import OpenPypeModule, IHostAddon
from ayon_core.addon import AYONAddon, IHostAddon
from ayon_core.lib import Logger

FUSION_HOST_DIR = os.path.dirname(os.path.abspath(__file__))
Expand Down Expand Up @@ -48,13 +48,10 @@ def get_fusion_version(app_name):
)


class FusionAddon(OpenPypeModule, IHostAddon):
class FusionAddon(AYONAddon, IHostAddon):
name = "fusion"
host_name = "fusion"

def initialize(self, module_settings):
self.enabled = True

def get_launch_hook_paths(self, app):
if app.host_name != self.host_name:
return []
Expand Down
7 changes: 2 additions & 5 deletions client/ayon_core/hosts/harmony/addon.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import os
from ayon_core.modules import OpenPypeModule, IHostAddon
from ayon_core.addon import AYONAddon, IHostAddon

HARMONY_HOST_DIR = os.path.dirname(os.path.abspath(__file__))


class HarmonyAddon(OpenPypeModule, IHostAddon):
class HarmonyAddon(AYONAddon, IHostAddon):
name = "harmony"
host_name = "harmony"

def initialize(self, module_settings):
self.enabled = True

def add_implementation_envs(self, env, _app):
"""Modify environments to contain all required for implementation."""
openharmony_path = os.path.join(
Expand Down
7 changes: 2 additions & 5 deletions client/ayon_core/hosts/hiero/addon.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import os
import platform
from ayon_core.modules import OpenPypeModule, IHostAddon
from ayon_core.addon import AYONAddon, IHostAddon

HIERO_ROOT_DIR = os.path.dirname(os.path.abspath(__file__))


class HieroAddon(OpenPypeModule, IHostAddon):
class HieroAddon(AYONAddon, IHostAddon):
name = "hiero"
host_name = "hiero"

def initialize(self, module_settings):
self.enabled = True

def add_implementation_envs(self, env, _app):
# Add requirements to HIERO_PLUGIN_PATH
new_hiero_paths = [
Expand Down
7 changes: 2 additions & 5 deletions client/ayon_core/hosts/houdini/addon.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import os
from ayon_core.modules import OpenPypeModule, IHostAddon
from ayon_core.addon import AYONAddon, IHostAddon

HOUDINI_HOST_DIR = os.path.dirname(os.path.abspath(__file__))


class HoudiniAddon(OpenPypeModule, IHostAddon):
class HoudiniAddon(AYONAddon, IHostAddon):
name = "houdini"
host_name = "houdini"

def initialize(self, module_settings):
self.enabled = True

def add_implementation_envs(self, env, _app):
# Add requirements to HOUDINI_PATH and HOUDINI_MENU_PATH
startup_path = os.path.join(HOUDINI_HOST_DIR, "startup")
Expand Down
7 changes: 2 additions & 5 deletions client/ayon_core/hosts/max/addon.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
# -*- coding: utf-8 -*-
import os
from ayon_core.modules import OpenPypeModule, IHostAddon
from ayon_core.addon import AYONAddon, IHostAddon

MAX_HOST_DIR = os.path.dirname(os.path.abspath(__file__))


class MaxAddon(OpenPypeModule, IHostAddon):
class MaxAddon(AYONAddon, IHostAddon):
name = "max"
host_name = "max"

def initialize(self, module_settings):
self.enabled = True

def add_implementation_envs(self, env, _app):
# Remove auto screen scale factor for Qt
# - let 3dsmax decide it's value
Expand Down
7 changes: 2 additions & 5 deletions client/ayon_core/hosts/maya/addon.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import os
from ayon_core.modules import OpenPypeModule, IHostAddon
from ayon_core.addon import AYONAddon, IHostAddon

MAYA_ROOT_DIR = os.path.dirname(os.path.abspath(__file__))


class MayaAddon(OpenPypeModule, IHostAddon):
class MayaAddon(AYONAddon, IHostAddon):
name = "maya"
host_name = "maya"

def initialize(self, module_settings):
self.enabled = True

def add_implementation_envs(self, env, _app):
# Add requirements to PYTHONPATH
new_python_paths = [
Expand Down
7 changes: 2 additions & 5 deletions client/ayon_core/hosts/nuke/addon.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import os
import platform
from ayon_core.modules import OpenPypeModule, IHostAddon
from ayon_core.addon import AYONAddon, IHostAddon

NUKE_ROOT_DIR = os.path.dirname(os.path.abspath(__file__))


class NukeAddon(OpenPypeModule, IHostAddon):
class NukeAddon(AYONAddon, IHostAddon):
name = "nuke"
host_name = "nuke"

def initialize(self, module_settings):
self.enabled = True

def add_implementation_envs(self, env, _app):
# Add requirements to NUKE_PATH
new_nuke_paths = [
Expand Down
7 changes: 2 additions & 5 deletions client/ayon_core/hosts/photoshop/addon.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import os
from ayon_core.modules import OpenPypeModule, IHostAddon
from ayon_core.addon import AYONAddon, IHostAddon

PHOTOSHOP_HOST_DIR = os.path.dirname(os.path.abspath(__file__))


class PhotoshopAddon(OpenPypeModule, IHostAddon):
class PhotoshopAddon(AYONAddon, IHostAddon):
name = "photoshop"
host_name = "photoshop"

def initialize(self, module_settings):
self.enabled = True

def add_implementation_envs(self, env, _app):
"""Modify environments to contain all required for implementation."""
defaults = {
Expand Down
7 changes: 2 additions & 5 deletions client/ayon_core/hosts/resolve/addon.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import os

from ayon_core.modules import OpenPypeModule, IHostAddon
from ayon_core.addon import AYONAddon, IHostAddon

from .utils import RESOLVE_ROOT_DIR


class ResolveAddon(OpenPypeModule, IHostAddon):
class ResolveAddon(AYONAddon, IHostAddon):
name = "resolve"
host_name = "resolve"

def initialize(self, module_settings):
self.enabled = True

def get_launch_hook_paths(self, app):
if app.host_name != self.host_name:
return []
Expand Down
7 changes: 2 additions & 5 deletions client/ayon_core/hosts/substancepainter/addon.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import os
from ayon_core.modules import OpenPypeModule, IHostAddon
from ayon_core.addon import AYONAddon, IHostAddon

SUBSTANCE_HOST_DIR = os.path.dirname(os.path.abspath(__file__))


class SubstanceAddon(OpenPypeModule, IHostAddon):
class SubstanceAddon(AYONAddon, IHostAddon):
name = "substancepainter"
host_name = "substancepainter"

def initialize(self, module_settings):
self.enabled = True

def add_implementation_envs(self, env, _app):
# Add requirements to SUBSTANCE_PAINTER_PLUGINS_PATH
plugin_path = os.path.join(SUBSTANCE_HOST_DIR, "deploy")
Expand Down
11 changes: 5 additions & 6 deletions client/ayon_core/hosts/traypublisher/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,22 @@

from ayon_core.lib import get_ayon_launcher_args
from ayon_core.lib.execute import run_detached_process
from ayon_core.modules import (
from ayon_core.addon import (
click_wrap,
OpenPypeModule,
AYONAddon,
ITrayAction,
IHostAddon,
)

TRAYPUBLISH_ROOT_DIR = os.path.dirname(os.path.abspath(__file__))


class TrayPublishAddon(OpenPypeModule, IHostAddon, ITrayAction):
class TrayPublishAddon(AYONAddon, IHostAddon, ITrayAction):
label = "Publisher"
name = "traypublisher"
host_name = "traypublisher"

def initialize(self, modules_settings):
self.enabled = True
def initialize(self, settings):
self.publish_paths = [
os.path.join(TRAYPUBLISH_ROOT_DIR, "plugins", "publish")
]
Expand All @@ -36,7 +35,7 @@ def connect_with_addons(self, enabled_modules):

def run_traypublisher(self):
args = get_ayon_launcher_args(
"module", self.name, "launch"
"addon", self.name, "launch"
)
run_detached_process(args)

Expand Down
7 changes: 2 additions & 5 deletions client/ayon_core/hosts/tvpaint/addon.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from ayon_core.modules import OpenPypeModule, IHostAddon
from ayon_core.addon import AYONAddon, IHostAddon

TVPAINT_ROOT_DIR = os.path.dirname(os.path.abspath(__file__))

Expand All @@ -12,13 +12,10 @@ def get_launch_script_path():
)


class TVPaintAddon(OpenPypeModule, IHostAddon):
class TVPaintAddon(AYONAddon, IHostAddon):
name = "tvpaint"
host_name = "tvpaint"

def initialize(self, module_settings):
self.enabled = True

def add_implementation_envs(self, env, _app):
"""Modify environments to contain all required for implementation."""

Expand Down
Loading
Loading