summaryrefslogtreecommitdiff
path: root/libmat2/__init__.py
diff options
context:
space:
mode:
authorAntoine Tenart2019-03-27 18:53:18 +0100
committerAntoine Tenart2019-03-29 19:29:28 +0100
commitd454ef5b8e867b4827dfc0d1cef818d4f94833c7 (patch)
tree918719b0545f247eb77b6c92533f250ac4ec28cb /libmat2/__init__.py
parentc824a68dd8cba7ff567f54bf65d22d46438d326b (diff)
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>
Diffstat (limited to 'libmat2/__init__.py')
-rw-r--r--libmat2/__init__.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/libmat2/__init__.py b/libmat2/__init__.py
index 1d945d4..46e56b3 100644
--- a/libmat2/__init__.py
+++ b/libmat2/__init__.py
@@ -38,13 +38,14 @@ DEPENDENCIES = {
38 'Mutagen': 'mutagen', 38 'Mutagen': 'mutagen',
39 } 39 }
40 40
41CMD_DEPENDENCIES = {
42 'Exiftool': exiftool._get_exiftool_path,
43 'Ffmpeg': video._get_ffmpeg_path,
44 }
41 45
42def check_dependencies() -> Dict[str, bool]: 46def check_dependencies() -> Dict[str, bool]:
43 ret = collections.defaultdict(bool) # type: Dict[str, bool] 47 ret = collections.defaultdict(bool) # type: Dict[str, bool]
44 48
45 ret['Exiftool'] = bool(exiftool._get_exiftool_path())
46 ret['Ffmpeg'] = bool(video._get_ffmpeg_path())
47
48 for key, value in DEPENDENCIES.items(): 49 for key, value in DEPENDENCIES.items():
49 ret[key] = True 50 ret[key] = True
50 try: 51 try:
@@ -52,6 +53,13 @@ def check_dependencies() -> Dict[str, bool]:
52 except ImportError: # pragma: no cover 53 except ImportError: # pragma: no cover
53 ret[key] = False # pragma: no cover 54 ret[key] = False # pragma: no cover
54 55
56 for key, value in CMD_DEPENDENCIES.items():
57 ret[key] = True
58 try:
59 value()
60 except RuntimeError: # pragma: no cover
61 ret[key] = False
62
55 return ret 63 return ret
56 64
57 65