mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 08:24:53 +01:00
Merge pull request #4011 from pypeclub/bugfix/tools_discovery_for_py2
General: Fix python 2 compatibility of ffmpeg and oiio tools discovery
This commit is contained in:
commit
38f2484f99
1 changed files with 24 additions and 24 deletions
|
|
@ -195,6 +195,28 @@ def find_tool_in_custom_paths(paths, tool, validation_func=None):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def _check_args_returncode(args):
|
||||||
|
try:
|
||||||
|
# Python 2 compatibility where DEVNULL is not available
|
||||||
|
if hasattr(subprocess, "DEVNULL"):
|
||||||
|
proc = subprocess.Popen(
|
||||||
|
args,
|
||||||
|
stdout=subprocess.DEVNULL,
|
||||||
|
stderr=subprocess.DEVNULL,
|
||||||
|
)
|
||||||
|
proc.wait()
|
||||||
|
else:
|
||||||
|
with open(os.devnull, "w") as devnull:
|
||||||
|
proc = subprocess.Popen(
|
||||||
|
args, stdout=devnull, stderr=devnull,
|
||||||
|
)
|
||||||
|
proc.wait()
|
||||||
|
|
||||||
|
except Exception:
|
||||||
|
return False
|
||||||
|
return proc.returncode == 0
|
||||||
|
|
||||||
|
|
||||||
def _oiio_executable_validation(filepath):
|
def _oiio_executable_validation(filepath):
|
||||||
"""Validate oiio tool executable if can be executed.
|
"""Validate oiio tool executable if can be executed.
|
||||||
|
|
||||||
|
|
@ -223,18 +245,7 @@ def _oiio_executable_validation(filepath):
|
||||||
if not filepath:
|
if not filepath:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
return _check_args_returncode([filepath, "--help"])
|
||||||
proc = subprocess.Popen(
|
|
||||||
[filepath, "--help"],
|
|
||||||
stdout=subprocess.DEVNULL,
|
|
||||||
stderr=subprocess.DEVNULL,
|
|
||||||
)
|
|
||||||
proc.wait()
|
|
||||||
return proc.returncode == 0
|
|
||||||
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def get_oiio_tools_path(tool="oiiotool"):
|
def get_oiio_tools_path(tool="oiiotool"):
|
||||||
|
|
@ -302,18 +313,7 @@ def _ffmpeg_executable_validation(filepath):
|
||||||
if not filepath:
|
if not filepath:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
return _check_args_returncode([filepath, "-version"])
|
||||||
proc = subprocess.Popen(
|
|
||||||
[filepath, "-version"],
|
|
||||||
stdout=subprocess.DEVNULL,
|
|
||||||
stderr=subprocess.DEVNULL,
|
|
||||||
)
|
|
||||||
proc.wait()
|
|
||||||
return proc.returncode == 0
|
|
||||||
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def get_ffmpeg_tool_path(tool="ffmpeg"):
|
def get_ffmpeg_tool_path(tool="ffmpeg"):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue