1
0
mirror of synced 2024-11-21 16:54:23 +01:00

libmat2: fix dependency checks for cmd line utilities

The command line checks for command line utilities are done by trying to
access the executables and by throwing an exception when not found. This
lead to:
- The mat2 cmd line --check-dependencies option failing.
- The ffmpeg unit tests failing when ffmpeg isn't installed (even though
  it's an optional dependency).

This patch fixes it.

Signed-off-by: Antoine Tenart <antoine.tenart@ack.tf>
This commit is contained in:
Antoine Tenart 2019-03-27 18:53:18 +01:00
parent c824a68dd8
commit d454ef5b8e

View File

@ -38,13 +38,14 @@ DEPENDENCIES = {
'Mutagen': 'mutagen',
}
CMD_DEPENDENCIES = {
'Exiftool': exiftool._get_exiftool_path,
'Ffmpeg': video._get_ffmpeg_path,
}
def check_dependencies() -> Dict[str, bool]:
ret = collections.defaultdict(bool) # type: Dict[str, bool]
ret['Exiftool'] = bool(exiftool._get_exiftool_path())
ret['Ffmpeg'] = bool(video._get_ffmpeg_path())
for key, value in DEPENDENCIES.items():
ret[key] = True
try:
@ -52,6 +53,13 @@ def check_dependencies() -> Dict[str, bool]:
except ImportError: # pragma: no cover
ret[key] = False # pragma: no cover
for key, value in CMD_DEPENDENCIES.items():
ret[key] = True
try:
value()
except RuntimeError: # pragma: no cover
ret[key] = False
return ret