Skip to content

ayon_third_party

ThirdPartyDistAddon

Bases: AYONAddon, ITrayAddon

Addon to deploy 3rd party binary dependencies.

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

Cares about supplying ffmpeg and oiiotool executables.

Source code in client/ayon_third_party/addon.py
11
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
class ThirdPartyDistAddon(AYONAddon, ITrayAddon):
    """Addon to deploy 3rd party binary dependencies.

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

    Cares about supplying ffmpeg and oiiotool executables.
    """

    name = ADDON_NAME
    version = __version__

    def initialize(self, settings):
        self._download_window = None

    def tray_exit(self):
        pass

    def tray_menu(self, tray_menu):
        pass

    def tray_init(self):
        pass

    def tray_start(self):
        download_ffmpeg = is_ffmpeg_download_needed()
        download_oiio = is_oiio_download_needed()
        if not download_oiio and not download_ffmpeg:
            return

        from .download_ui import show_download_window

        download_window = show_download_window(
            download_ffmpeg, download_oiio
        )
        download_window.finished.connect(self._on_download_finish)
        download_window.start()
        self._download_window = download_window

    def _on_download_finish(self):
        self._download_window.close()
        self._download_window = None

download_ffmpeg(progress=None)

Download ffmpeg from server.

Todos

Add safeguard to avoid downloading of the file from multiple processes at once.

Parameters:

Name Type Description Default
progress TransferProgress

Keep track about download.

None
Source code in client/ayon_third_party/utils.py
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
def download_ffmpeg(
    progress: Optional[TransferProgress] = None,
):
    """Download ffmpeg from server.

    Todos:
        Add safeguard to avoid downloading of the file from multiple
            processes at once.

    Args:
        progress (ayon_api.TransferProgress): Keep track about download.

    """

    files_info = get_server_files_info()
    file_info = _find_file_info("ffmpeg", files_info)
    if file_info is None:
        raise ValueError((
            "Couldn't find ffmpeg source file for platform '{}'"
        ).format(platform.system()))

    dirpath = get_downloaded_ffmpeg_root()
    log.debug(f"Downloading ffmpeg into: '{dirpath}'")
    if not _download_file(file_info, dirpath, progress=progress):
        log.debug("Other processed already downloaded and extracted ffmpeg.")

    _FFmpegArgs.download_needed = False
    _FFmpegArgs.downloaded_root = NOT_SET

get_ffmpeg_arguments(tool_name='ffmpeg')

Get arguments to run one of ffmpeg tools.

Parameters:

Name Type Description Default
tool_name FFmpegToolname

Name of tool for which arguments should be returned.

'ffmpeg'

Returns:

Type Description
Optional[List[str]]

list[str]: Path to OpenImageIO directory.

Source code in client/ayon_third_party/utils.py
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
def get_ffmpeg_arguments(
    tool_name: "FFmpegToolname" = "ffmpeg"
) -> Optional[List[str]]:
    """Get arguments to run one of ffmpeg tools.

    Args:
        tool_name (FFmpegToolname): Name of
            tool for which arguments should be returned.

    Returns:
        list[str]: Path to OpenImageIO directory.

    """
    args = _FFmpegArgs.tools.get(tool_name, NOT_SET)
    if args is NOT_SET:
        args = _fill_ffmpeg_tool_args(tool_name)
    return copy.deepcopy(args)

get_oiio_arguments(tool_name='oiiotool')

Get arguments to run one of OpenImageIO tools.

Possible OIIO tools

oiiotool, maketx, iv, iinfo, igrep, idiff, iconvert

Parameters:

Name Type Description Default
tool_name OIIOToolName

Name of OIIO tool.

'oiiotool'

Returns:

Name Type Description
str Optional[List[str]]

Path to zip info file.

Source code in client/ayon_third_party/utils.py
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
def get_oiio_arguments(
    tool_name: "OIIOToolName" = "oiiotool"
) -> Optional[List[str]]:
    """Get arguments to run one of OpenImageIO tools.

    Possible OIIO tools:
        oiiotool, maketx, iv, iinfo, igrep, idiff, iconvert

    Args:
        tool_name (OIIOToolName): Name of OIIO tool.

    Returns:
        str: Path to zip info file.

    """
    args = _OIIOArgs.tools.get(tool_name, NOT_SET)
    if args is NOT_SET:
        args = _fill_oiio_tool_args(tool_name)
    return copy.deepcopy(args)

is_ffmpeg_download_needed(addon_settings=None)

Check if is download needed.

Returns:

Name Type Description
bool bool

Should be config downloaded.

Source code in client/ayon_third_party/utils.py
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
def is_ffmpeg_download_needed(
    addon_settings: Optional[Dict[str, Any]] = None
) -> bool:
    """Check if is download needed.

    Returns:
        bool: Should be config downloaded.

    """
    if _FFmpegArgs.download_needed is not None:
        return _FFmpegArgs.download_needed

    if addon_settings is None:
        addon_settings = get_addon_settings()
    ffmpeg_settings = addon_settings["ffmpeg"]
    download_needed = False
    if ffmpeg_settings["use_downloaded"]:
        # Check what is required by server
        ffmpeg_root = get_downloaded_ffmpeg_root()
        progress_info = {}
        if ffmpeg_root:
            progress_path = os.path.join(
                ffmpeg_root, DIST_PROGRESS_FILENAME
            )
            progress_info = _read_progress_file(progress_path)
        download_needed = progress_info.get("state") != "done"

    _FFmpegArgs.download_needed = download_needed
    return _FFmpegArgs.download_needed

is_oiio_download_needed(addon_settings=None)

Check if is download needed.

Returns:

Name Type Description
bool bool

Should be config downloaded.

Source code in client/ayon_third_party/utils.py
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
def is_oiio_download_needed(
    addon_settings: Optional[Dict[str, Any]] = None
) -> bool:
    """Check if is download needed.

    Returns:
        bool: Should be config downloaded.

    """
    if _OIIOArgs.download_needed is not None:
        return _OIIOArgs.download_needed

    if addon_settings is None:
        addon_settings = get_addon_settings()
    oiio_settings = addon_settings["oiio"]

    download_needed = False
    if oiio_settings["use_downloaded"]:
        oiio_root = get_downloaded_oiio_root()
        progress_info = {}
        if oiio_root:
            progress_path = os.path.join(
                oiio_root, DIST_PROGRESS_FILENAME
            )
            progress_info = _read_progress_file(progress_path)
        download_needed = progress_info.get("state") != "done"
    _OIIOArgs.download_needed = download_needed
    return _OIIOArgs.download_needed