mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
added startup validations of ffmpeg and oiio tool
This commit is contained in:
parent
cfa6687a8f
commit
e24b142962
1 changed files with 60 additions and 0 deletions
60
start.py
60
start.py
|
|
@ -96,6 +96,7 @@ Attributes:
|
|||
import os
|
||||
import re
|
||||
import sys
|
||||
import platform
|
||||
import traceback
|
||||
import subprocess
|
||||
import site
|
||||
|
|
@ -339,6 +340,60 @@ def set_modules_environments():
|
|||
os.environ.update(env)
|
||||
|
||||
|
||||
def is_tool(name):
|
||||
try:
|
||||
import os.errno as errno
|
||||
except ImportError:
|
||||
import errno
|
||||
|
||||
try:
|
||||
devnull = open(os.devnull, "w")
|
||||
subprocess.Popen(
|
||||
[name], stdout=devnull, stderr=devnull
|
||||
).communicate()
|
||||
except OSError as exc:
|
||||
if exc.errno == errno.ENOENT:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def _startup_validations():
|
||||
"""Validations before OpenPype starts."""
|
||||
_validate_thirdparty_binaries()
|
||||
|
||||
|
||||
def _validate_thirdparty_binaries():
|
||||
"""Check existence of thirdpart executables."""
|
||||
low_platform = platform.system().lower()
|
||||
binary_vendors_dir = os.path.join(
|
||||
os.environ["OPENPYPE_ROOT"],
|
||||
"vendor",
|
||||
"bin"
|
||||
)
|
||||
|
||||
error_msg = (
|
||||
"Missing binary dependency {}. Please fetch thirdparty dependencies."
|
||||
)
|
||||
# Validate existence of FFmpeg
|
||||
ffmpeg_dir = os.path.join(binary_vendors_dir, "ffmpeg", low_platform)
|
||||
if low_platform == "windows":
|
||||
ffmpeg_dir = os.path.join(ffmpeg_dir, "bin")
|
||||
ffmpeg_executable = os.path.join(ffmpeg_dir, "ffmpeg")
|
||||
if not is_tool(ffmpeg_executable):
|
||||
raise RuntimeError(error_msg.format("FFmpeg"))
|
||||
|
||||
# Validate existence of OpenImageIO (not on MacOs)
|
||||
if low_platform != "darwin":
|
||||
oiio_tool_path = os.path.join(
|
||||
binary_vendors_dir,
|
||||
"oiio",
|
||||
low_platform,
|
||||
"oiio_tool"
|
||||
)
|
||||
if not is_tool(oiio_tool_path):
|
||||
raise RuntimeError(error_msg.format("OpenImageIO"))
|
||||
|
||||
|
||||
def _process_arguments() -> tuple:
|
||||
"""Process command line arguments.
|
||||
|
||||
|
|
@ -767,6 +822,11 @@ def boot():
|
|||
# ------------------------------------------------------------------------
|
||||
os.environ["OPENPYPE_ROOT"] = OPENPYPE_ROOT
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
# Do necessary startup validations
|
||||
# ------------------------------------------------------------------------
|
||||
_startup_validations()
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
# Play animation
|
||||
# ------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue