From 56d2c4aa5fea506abb15d71b53aea23b9dd3398b Mon Sep 17 00:00:00 2001 From: tguinot Date: Mon, 10 Feb 2020 03:31:07 +0100 Subject: Add which pathfinding for executables --- libmat2/exiftool.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'libmat2/exiftool.py') 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 import json import logging import os +import shutil import subprocess from typing import Dict, Union, Set @@ -71,14 +72,12 @@ class ExiftoolParser(abstract.AbstractParser): @functools.lru_cache() def _get_exiftool_path() -> str: # pragma: no cover - possible_pathes = { - '/usr/bin/exiftool', # debian/fedora - '/usr/bin/vendor_perl/exiftool', # archlinux - } + which_path = shutil.which('exiftool') + if which_path: + return which_path - for possible_path in possible_pathes: - if os.path.isfile(possible_path): - if os.access(possible_path, os.X_OK): - return possible_path + # Exiftool on Arch Linux has a weird path + if os.access('/usr/bin/vendor_perl/exiftool', os.X_OK): + return '/usr/bin/vendor_perl/exiftool' raise RuntimeError("Unable to find exiftool") -- cgit v1.3