summaryrefslogtreecommitdiff
path: root/libmat2/exiftool.py
diff options
context:
space:
mode:
authortguinot2020-02-10 03:31:07 +0100
committerjvoisin2020-02-11 17:23:11 +0100
commit56d2c4aa5fea506abb15d71b53aea23b9dd3398b (patch)
tree16a35a9e88694e227584513d7b0e4a3499844e67 /libmat2/exiftool.py
parent12f23e0150906ccfac03254276a6af4bbe74f7c8 (diff)
Add which pathfinding for executables
Diffstat (limited to 'libmat2/exiftool.py')
-rw-r--r--libmat2/exiftool.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/libmat2/exiftool.py b/libmat2/exiftool.py
index 1ce60a1..eb65b2a 100644
--- a/libmat2/exiftool.py
+++ b/libmat2/exiftool.py
@@ -2,6 +2,7 @@ import functools
2import json 2import json
3import logging 3import logging
4import os 4import os
5import shutil
5import subprocess 6import subprocess
6from typing import Dict, Union, Set 7from typing import Dict, Union, Set
7 8
@@ -71,14 +72,12 @@ class ExiftoolParser(abstract.AbstractParser):
71 72
72@functools.lru_cache() 73@functools.lru_cache()
73def _get_exiftool_path() -> str: # pragma: no cover 74def _get_exiftool_path() -> str: # pragma: no cover
74 possible_pathes = { 75 which_path = shutil.which('exiftool')
75 '/usr/bin/exiftool', # debian/fedora 76 if which_path:
76 '/usr/bin/vendor_perl/exiftool', # archlinux 77 return which_path
77 }
78 78
79 for possible_path in possible_pathes: 79 # Exiftool on Arch Linux has a weird path
80 if os.path.isfile(possible_path): 80 if os.access('/usr/bin/vendor_perl/exiftool', os.X_OK):
81 if os.access(possible_path, os.X_OK): 81 return '/usr/bin/vendor_perl/exiftool'
82 return possible_path
83 82
84 raise RuntimeError("Unable to find exiftool") 83 raise RuntimeError("Unable to find exiftool")