Skip to content

ayon_usd

USD Addon for AYON - client part.

USDAddon

Bases: AYONAddon, ITrayAddon, IPluginPaths

Addon to add USD Support to AYON.

Addon can also skip distribution of binaries from server and can use path/arguments defined by server.

Cares about supplying USD Framework.

Source code in client/ayon_usd/addon.py
12
13
14
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
class USDAddon(AYONAddon, ITrayAddon, IPluginPaths):
    """Addon to add USD Support to AYON.

    Addon can also skip distribution of binaries from server and can
    use path/arguments defined by server.

    Cares about supplying USD Framework.
    """

    name = "usd"
    version = __version__
    _download_window = None

    def tray_init(self):
        """Initialize tray module."""
        super(USDAddon, self).tray_init()

    def initialize(self, studio_settings):
        """Initialize USD Addon."""
        self._download_window = None

    def tray_start(self):
        """Start tray module.

        Skip downloading base USD, not needed now.
        """
        pass

    def tray_exit(self):
        """Exit tray module."""
        pass

    def tray_menu(self, tray_menu):
        """Add menu items to tray menu."""
        pass

    def get_launch_hook_paths(self):
        """Get paths to launch hooks."""
        return [os.path.join(USD_ADDON_DIR, "hooks")]

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

get_launch_hook_paths()

Get paths to launch hooks.

Source code in client/ayon_usd/addon.py
48
49
50
def get_launch_hook_paths(self):
    """Get paths to launch hooks."""
    return [os.path.join(USD_ADDON_DIR, "hooks")]

initialize(studio_settings)

Initialize USD Addon.

Source code in client/ayon_usd/addon.py
29
30
31
def initialize(self, studio_settings):
    """Initialize USD Addon."""
    self._download_window = None

tray_exit()

Exit tray module.

Source code in client/ayon_usd/addon.py
40
41
42
def tray_exit(self):
    """Exit tray module."""
    pass

tray_init()

Initialize tray module.

Source code in client/ayon_usd/addon.py
25
26
27
def tray_init(self):
    """Initialize tray module."""
    super(USDAddon, self).tray_init()

tray_menu(tray_menu)

Add menu items to tray menu.

Source code in client/ayon_usd/addon.py
44
45
46
def tray_menu(self, tray_menu):
    """Add menu items to tray menu."""
    pass

tray_start()

Start tray module.

Skip downloading base USD, not needed now.

Source code in client/ayon_usd/addon.py
33
34
35
36
37
38
def tray_start(self):
    """Start tray module.

    Skip downloading base USD, not needed now.
    """
    pass

extract_zip_file(progress_item, zip_file_path, dest_dir)

Extract a zip file to a destination directory.

Parameters:

Name Type Description Default
zip_file_path str

The path to the zip file.

required
dest_dir str

The directory where the zip file should be extracted.

required

Returns:

Name Type Description
str str

Path to the extracted content directory.

Note

On Windows, this function handles paths longer than MAX_PATH (260 chars) by using the \?\ long path prefix.

Source code in client/ayon_usd/ayon_bin_client/ayon_bin_distro/util/zip.py
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
def extract_zip_file(progress_item, zip_file_path: str, dest_dir: str) -> str:
    """Extract a zip file to a destination directory.

    Args:
        zip_file_path (str): The path to the zip file.
        dest_dir (str): The directory where the zip file should be extracted.

    Returns:
        str: Path to the extracted content directory.

    Note:
        On Windows, this function handles paths longer than MAX_PATH (260 chars)
        by using the \\?\ long path prefix.
    """
    with ZipFileLongPaths(zip_file_path, "r") as zip_ref:
        zip_ref.extractall(dest_dir)

    foulder_name = os.path.basename(zip_file_path).replace(".zip", "")
    return os.path.join(dest_dir, foulder_name)

get_download_dir(create_if_missing=True)

Dir path where files are downloaded.

Parameters:

Name Type Description Default
create_if_missing bool

Create dir if missing.

True

Returns:

Name Type Description
str

Path to download dir.

Source code in client/ayon_usd/utils.py
51
52
53
54
55
56
57
58
59
60
61
62
63
def get_download_dir(create_if_missing=True):
    """Dir path where files are downloaded.

    Args:
        create_if_missing (bool): Create dir if missing.

    Returns:
        str: Path to download dir.

    """
    if create_if_missing and not os.path.exists(DOWNLOAD_DIR):
        os.makedirs(DOWNLOAD_DIR, exist_ok=True)
    return DOWNLOAD_DIR