Skip to content

AYON_in_flame

app_initialized(parent=None)

Inicialization of Framework

Parameters:

Name Type Description Default
parent obj

Parent object. Defaults to None.

None
Source code in client/ayon_flame/startup/AYON_in_flame.py
157
158
159
160
161
162
163
164
165
166
167
168
def app_initialized(parent=None):
    """Inicialization of Framework

    Args:
        parent (obj, optional): Parent object. Defaults to None.
    """
    flame_api.CTX.app_framework = flame_api.FlameAppFramework()

    print(f"{flame_api.CTX.app_framework.bundle_name} initializing")

    load_apps()
    check_project_ocio_config()

ayon_flame_install()

Registering AYON in context

Source code in client/ayon_flame/startup/AYON_in_flame.py
28
29
30
31
32
def ayon_flame_install():
    """Registering AYON in context
    """
    flame_host = FlameHost()
    install_host(flame_host)

check_project_ocio_config()

Warn if Flame project OCIO config and AYON OCIO config differs.

Flame project OCIO config is only set at project creation, so it can differ from the current config set in AYON (used at publish).

Source code in client/ayon_flame/startup/AYON_in_flame.py
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
def check_project_ocio_config():
    """Warn if Flame project OCIO config and AYON OCIO config differs.

    Flame project OCIO config is only set at project creation,
    so it can differ from the current config set in AYON (used at publish).
    """
    import flame
    from ayon_core.pipeline.context_tools import get_current_project_settings

    # Flame < 2026 projects use SynColor not OCIO.
    if int(flame.get_version_major()) < 2026:
        return

    # No OCIO config set.
    ayon_ocio_config = os.getenv("OCIO")
    if not ayon_ocio_config:
        return

    project_name = flame_api.get_current_project().name
    try:
        # Color management is disabled.
        imageio_flame = get_current_project_settings()["flame"]["imageio"]
        if imageio_flame.get("activate_host_color_management") is False:
            return

        project_ocio_config = flame_api.get_project_ocio_config(project_name)

    except Exception as error:
        print(f"!!!! not able to check project OCIO config: {error} !!!!")
        return

    if (
        project_ocio_config
        and os.path.realpath(project_ocio_config)
        == os.path.realpath(ayon_ocio_config)
    ):
        return

    message = (
        f"Flame project '{project_name}' OCIO config does not match "
        "AYON OCIO config, published colorspaces might be wrong.\n\n"
        f"- Flame project: {project_ocio_config}\n"
        f"- AYON: {ayon_ocio_config}"
    )
    print(f"AYON: {message}")
    flame.messages.show_in_dialog(
        "AYON: OCIO config mismatch",
        message,
        "warning",
        ["OK"],
    )

cleanup()

Cleaning up Flame framework context

Source code in client/ayon_flame/startup/AYON_in_flame.py
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
def cleanup():
    """Cleaning up Flame framework context
    """
    if flame_api.CTX.flame_apps:
        print(
            f"`{__file__}` cleaning up flame_apps:\n "
            f"{pformat(flame_api.CTX.flame_apps)}\n"
        )
        while len(flame_api.CTX.flame_apps):
            app = flame_api.CTX.flame_apps.pop()
            print(f"`{__file__}` removing : {app.name}")
            del app
        flame_api.CTX.flame_apps = []

    if flame_api.CTX.app_framework:
        print(f"AYON\t: {flame_api.CTX.app_framework.bundle_name} cleaning up")
        flame_api.CTX.app_framework.save_prefs()
        flame_api.CTX.app_framework = None

exception_handler(exctype, value, _traceback)

Exception handler for improving UX

Parameters:

Name Type Description Default
exctype str

type of exception

required
value str

exception value

required
tb str

traceback to show

required
Source code in client/ayon_flame/startup/AYON_in_flame.py
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
def exception_handler(exctype, value, _traceback):
    """Exception handler for improving UX

    Args:
        exctype (str): type of exception
        value (str): exception value
        tb (str): traceback to show
    """
    msg = f"AYON: Python exception {value} in {exctype}"
    mbox = QtWidgets.QMessageBox()
    mbox.setText(msg)
    mbox.setDetailedText(
        pformat(traceback.format_exception(exctype, value, _traceback)))
    mbox.setStyleSheet("QLabel{min-width: 800px;}")
    mbox.exec_()
    sys.__excepthook__(exctype, value, _traceback)

get_batch_custom_ui_actions()

Hook to create submenu in batch

Returns:

Name Type Description
list

menu object

Source code in client/ayon_flame/startup/AYON_in_flame.py
270
271
272
273
274
275
276
277
278
279
def get_batch_custom_ui_actions():
    """Hook to create submenu in batch

    Returns:
        list: menu object
    """
    # install AYON and the host
    ayon_flame_install()

    return _build_app_menu("FlameMenuBatch")

get_main_menu_custom_ui_actions()

Hook to create submenu in start menu

Returns:

Name Type Description
list

menu object

Source code in client/ayon_flame/startup/AYON_in_flame.py
246
247
248
249
250
251
252
253
254
255
def get_main_menu_custom_ui_actions():
    """Hook to create submenu in start menu

    Returns:
        list: menu object
    """
    # install AYON and the host
    ayon_flame_install()

    return _build_app_menu("FlameMenuProjectConnect")

get_media_panel_custom_ui_actions()

Hook to create submenu in desktop

Returns:

Name Type Description
list

menu object

Source code in client/ayon_flame/startup/AYON_in_flame.py
282
283
284
285
286
287
288
289
290
291
def get_media_panel_custom_ui_actions():
    """Hook to create submenu in desktop

    Returns:
        list: menu object
    """
    # install AYON and the host
    ayon_flame_install()

    return _build_app_menu("FlameMenuUniversal")

get_timeline_custom_ui_actions()

Hook to create submenu in timeline

Returns:

Name Type Description
list

menu object

Source code in client/ayon_flame/startup/AYON_in_flame.py
258
259
260
261
262
263
264
265
266
267
def get_timeline_custom_ui_actions():
    """Hook to create submenu in timeline

    Returns:
        list: menu object
    """
    # install AYON and the host
    ayon_flame_install()

    return _build_app_menu("FlameMenuTimeline")

load_apps()

Load available flame_apps into Flame framework

Source code in client/ayon_flame/startup/AYON_in_flame.py
81
82
83
84
85
86
87
88
89
90
91
92
def load_apps():
    """Load available flame_apps into Flame framework
    """
    flame_api.CTX.flame_apps.append(
        flame_api.FlameMenuProjectConnect(flame_api.CTX.app_framework))
    flame_api.CTX.flame_apps.append(
        flame_api.FlameMenuTimeline(flame_api.CTX.app_framework))
    flame_api.CTX.flame_apps.append(
        flame_api.FlameMenuBatch(flame_api.CTX.app_framework))
    flame_api.CTX.flame_apps.append(
        flame_api.FlameMenuUniversal(flame_api.CTX.app_framework))
    flame_api.CTX.app_framework.log.info("Apps are loaded")

project_changed_dict(info)

Hook for project change action

Parameters:

Name Type Description Default
info str

info text

required
Source code in client/ayon_flame/startup/AYON_in_flame.py
 95
 96
 97
 98
 99
100
101
def project_changed_dict(info):
    """Hook for project change action

    Args:
        info (str): info text
    """
    cleanup()

project_saved(project_name, save_time, is_auto_save)

Hook to activate when project is saved

Parameters:

Name Type Description Default
project_name str

name of project

required
save_time str

time when it was saved

required
is_auto_save bool

autosave is on or off

required
Source code in client/ayon_flame/startup/AYON_in_flame.py
234
235
236
237
238
239
240
241
242
243
def project_saved(project_name, save_time, is_auto_save):
    """Hook to activate when project is saved

    Args:
        project_name (str): name of project
        save_time (str): time when it was saved
        is_auto_save (bool): autosave is on or off
    """
    if flame_api.CTX.app_framework:
        flame_api.CTX.app_framework.save_prefs()