Skip to content

ayon_kitsu

Addon class definition and Settings definition must be imported here.

If addon class or settings definition won't be here their definition won't be found by OpenPype discovery.

KitsuAddon

Bases: AYONAddon, IPluginPaths, ITrayAction

Kitsu addon class.

Source code in client/ayon_kitsu/addon.py
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
class KitsuAddon(AYONAddon, IPluginPaths, ITrayAction):
    """Kitsu addon class."""

    label = "Kitsu Connect"
    name = "kitsu"
    version = __version__

    def initialize(self, settings):
        """Initialization of addon."""

        kitsu_settings = settings["kitsu"]
        # Add API URL schema
        kitsu_url = kitsu_settings["server"].strip()
        if kitsu_url:
            # Ensure web url
            if not kitsu_url.startswith("http"):
                kitsu_url = f"https://{kitsu_url}"

            kitsu_url = kitsu_url.rstrip("/")

            # Check for "/api" url validity
            if not kitsu_url.endswith("api"):
                kitsu_url = f"{kitsu_url}/api"

        self.server_url = kitsu_url

        # UI which must not be created at this time
        self._dialog = None

    def tray_init(self):
        """Tray init."""

        pass

    def tray_start(self):
        """Tray start."""
        from .credentials import (
            load_credentials,
            validate_credentials,
            set_credentials_envs,
        )

        login, password = load_credentials()

        if login is None or password is None:
            # TODO raise correct type
            raise

        # Check credentials, ask them if needed
        if validate_credentials(login, password):
            set_credentials_envs(login, password)
        else:
            self.show_dialog()

    def get_global_environments(self):
        """Kitsu's global environments."""
        return {"KITSU_SERVER": self.server_url}

    def _get_dialog(self):
        if self._dialog is None:
            from .kitsu_widgets import KitsuPasswordDialog

            self._dialog = KitsuPasswordDialog()

        return self._dialog

    def show_dialog(self):
        """Show dialog to log-in."""

        # Make sure dialog is created
        dialog = self._get_dialog()

        # Show dialog
        dialog.open()

    def on_action_trigger(self):
        """Implementation of abstract method for `ITrayAction`."""
        self.show_dialog()

    def get_plugin_paths(self):
        """Implementation of abstract method for `IPluginPaths`."""

        return {
            "publish": self.get_publish_plugin_paths(),
            # The laucher action is not working since AYON conversion
            # "actions": [os.path.join(KITSU_ROOT, "plugins", "launcher")],
        }

    def get_publish_plugin_paths(self, host_name=None):
        return [os.path.join(KITSU_ROOT, "plugins", "publish")]

get_global_environments()

Kitsu's global environments.

Source code in client/ayon_kitsu/addon.py
69
70
71
def get_global_environments(self):
    """Kitsu's global environments."""
    return {"KITSU_SERVER": self.server_url}

get_plugin_paths()

Implementation of abstract method for IPluginPaths.

Source code in client/ayon_kitsu/addon.py
 94
 95
 96
 97
 98
 99
100
101
def get_plugin_paths(self):
    """Implementation of abstract method for `IPluginPaths`."""

    return {
        "publish": self.get_publish_plugin_paths(),
        # The laucher action is not working since AYON conversion
        # "actions": [os.path.join(KITSU_ROOT, "plugins", "launcher")],
    }

initialize(settings)

Initialization of addon.

Source code in client/ayon_kitsu/addon.py
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
def initialize(self, settings):
    """Initialization of addon."""

    kitsu_settings = settings["kitsu"]
    # Add API URL schema
    kitsu_url = kitsu_settings["server"].strip()
    if kitsu_url:
        # Ensure web url
        if not kitsu_url.startswith("http"):
            kitsu_url = f"https://{kitsu_url}"

        kitsu_url = kitsu_url.rstrip("/")

        # Check for "/api" url validity
        if not kitsu_url.endswith("api"):
            kitsu_url = f"{kitsu_url}/api"

    self.server_url = kitsu_url

    # UI which must not be created at this time
    self._dialog = None

on_action_trigger()

Implementation of abstract method for ITrayAction.

Source code in client/ayon_kitsu/addon.py
90
91
92
def on_action_trigger(self):
    """Implementation of abstract method for `ITrayAction`."""
    self.show_dialog()

show_dialog()

Show dialog to log-in.

Source code in client/ayon_kitsu/addon.py
81
82
83
84
85
86
87
88
def show_dialog(self):
    """Show dialog to log-in."""

    # Make sure dialog is created
    dialog = self._get_dialog()

    # Show dialog
    dialog.open()

tray_init()

Tray init.

Source code in client/ayon_kitsu/addon.py
44
45
46
47
def tray_init(self):
    """Tray init."""

    pass

tray_start()

Tray start.

Source code in client/ayon_kitsu/addon.py
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
def tray_start(self):
    """Tray start."""
    from .credentials import (
        load_credentials,
        validate_credentials,
        set_credentials_envs,
    )

    login, password = load_credentials()

    if login is None or password is None:
        # TODO raise correct type
        raise

    # Check credentials, ask them if needed
    if validate_credentials(login, password):
        set_credentials_envs(login, password)
    else:
        self.show_dialog()

is_kitsu_enabled_in_settings(project_settings)

Check if kitsu is enabled in kitsu project settings.

This function expect settings for a specific project. It is not checking if kitsu is enabled in general.

Project settings gives option to disable kitsu integration per project. That should disable most of kitsu integration functionality, especially pipeline integration > publish plugins, and some automations like event server handlers.

Parameters:

Name Type Description Default
project_settings dict[str, Any]

Project settings.

required

Returns:

Name Type Description
bool

True if kitsu is enabled in project settings.

Source code in client/ayon_kitsu/addon.py
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
def is_kitsu_enabled_in_settings(project_settings):
    """Check if kitsu is enabled in kitsu project settings.

    This function expect settings for a specific project. It is not checking
    if kitsu is enabled in general.

    Project settings gives option to disable kitsu integration per project.
    That should disable most of kitsu integration functionality, especially
    pipeline integration > publish plugins, and some automations like event
    server handlers.

    Args:
        project_settings (dict[str, Any]): Project settings.

    Returns:
        bool: True if kitsu is enabled in project settings.
    """

    kitsu_enabled = project_settings.get("enabled")
    # If 'kitsu_enabled' is not set, we assume it is enabled.
    # - this is for backwards compatibility - remove in future
    if kitsu_enabled is None:
        return True
    return kitsu_enabled