Skip to content

utils

get_addons_dir()

Directory where addon packages are stored.

Path to addons is defined using python module 'appdirs' which

The path is stored into environment variable 'AYON_ADDONS_DIR'. Value of environment variable can be overriden, but we highly recommended to use that option only for development purposes.

Returns:

Name Type Description
str

Path to directory where addons should be downloaded.

Source code in common/ayon_common/distribution/utils.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
def get_addons_dir():
    """Directory where addon packages are stored.

    Path to addons is defined using python module 'appdirs' which

    The path is stored into environment variable 'AYON_ADDONS_DIR'.
    Value of environment variable can be overriden, but we highly recommended
    to use that option only for development purposes.

    Returns:
        str: Path to directory where addons should be downloaded.
    """

    addons_dir = os.environ.get("AYON_ADDONS_DIR")
    if not addons_dir:
        addons_dir = get_launcher_storage_dir(
            "addons", create=True
        )
        os.environ["AYON_ADDONS_DIR"] = addons_dir
    return addons_dir

get_dependencies_dir()

Directory where dependency packages are stored.

Path to addons is defined using python module 'appdirs' which

The path is stored into environment variable 'AYON_DEPENDENCIES_DIR'. Value of environment variable can be overriden, but we highly recommended to use that option only for development purposes.

Returns:

Name Type Description
str

Path to directory where dependency packages should be downloaded.

Source code in common/ayon_common/distribution/utils.py
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
def get_dependencies_dir():
    """Directory where dependency packages are stored.

    Path to addons is defined using python module 'appdirs' which

    The path is stored into environment variable 'AYON_DEPENDENCIES_DIR'.
    Value of environment variable can be overriden, but we highly recommended
    to use that option only for development purposes.

    Returns:
        str: Path to directory where dependency packages should be downloaded.
    """

    dependencies_dir = os.environ.get("AYON_DEPENDENCIES_DIR")
    if not dependencies_dir:
        dependencies_dir = get_launcher_storage_dir(
            "dependency_packages", create=True
        )
        os.environ["AYON_DEPENDENCIES_DIR"] = dependencies_dir
    return dependencies_dir

show_installer_issue_information(message, installer_path=None)

Show a message that something went wrong during installer distribution.

This will trigger a subprocess with UI message dialog.

Parameters:

Name Type Description Default
message str

Error message with description of an issue.

required
installer_path Optional[str]

Path to installer file so user can try to install it manually.

None
Source code in common/ayon_common/distribution/utils.py
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
def show_installer_issue_information(message, installer_path=None):
    """Show a message that something went wrong during installer distribution.

    This will trigger a subprocess with UI message dialog.

    Args:
        message (str): Error message with description of an issue.
        installer_path (Optional[str]): Path to installer file so user can
            try to install it manually.

    """
    sub_message = None
    if installer_path and os.path.exists(installer_path):
        sub_message = (
            "NOTE: Install file can be found here:"
            f"<br/><b>{installer_path}</b>"
        )
    _show_message_dialog(
        "AYON-launcher distribution",
        message,
        sub_message,
    )

show_missing_bundle_information(url, bundle_name, username, is_project_bundle)

Show missing bundle information window.

This function should be called when server does not have set bundle for production or staging, or when bundle that should be used is not available on server.

Using subprocess to show the dialog. Is blocking and is waiting until dialog is closed.

Parameters:

Name Type Description Default
url str

Server url where bundle is not set.

required
bundle_name Optional[str]

Name of bundle that was not found. Or 'None' if is missing bundle.

required
username Optional[str]

Username. Is used only when dev mode is enabled.

required
is_project_bundle bool

Missing bundle is project bundle.

required
Source code in common/ayon_common/distribution/utils.py
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
def show_missing_bundle_information(
    url: str,
    bundle_name: Optional[str],
    username: Optional[str],
    is_project_bundle: bool,
) -> None:
    """Show missing bundle information window.

    This function should be called when server does not have set bundle for
    production or staging, or when bundle that should be used is not available
    on server.

    Using subprocess to show the dialog. Is blocking and is waiting until
    dialog is closed.

    Args:
        url (str): Server url where bundle is not set.
        bundle_name (Optional[str]): Name of bundle that was not found. Or
            'None' if is missing bundle.
        username (Optional[str]): Username. Is used only when dev mode is
            enabled.
        is_project_bundle (bool): Missing bundle is project bundle.

    """
    ui_dir = os.path.join(os.path.dirname(__file__), "ui")
    script_path = os.path.join(ui_dir, "missing_bundle_window.py")
    args = get_ayon_launch_args(
        script_path,
        "--skip-bootstrap",
        "--url", url,
    )
    if bundle_name:
        args.extend(["--missing-bundle", bundle_name])

    if username:
        args.extend(["--user", username])

    if is_project_bundle:
        args.append("--is-project")
    subprocess.call(args)