summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortguinot2020-02-10 03:31:07 +0100
committerjvoisin2020-02-11 17:23:11 +0100
commit56d2c4aa5fea506abb15d71b53aea23b9dd3398b (patch)
tree16a35a9e88694e227584513d7b0e4a3499844e67
parent12f23e0150906ccfac03254276a6af4bbe74f7c8 (diff)
Add which pathfinding for executables
-rw-r--r--README.md6
-rw-r--r--libmat2/bubblewrap.py7
-rw-r--r--libmat2/exiftool.py15
-rw-r--r--libmat2/video.py9
4 files changed, 20 insertions, 17 deletions
diff --git a/README.md b/README.md
index 2aeb493..4e6a696 100644
--- a/README.md
+++ b/README.md
@@ -41,6 +41,12 @@ Nautilus, the default file manager of GNOME.
41 41
42Please note that mat2 requires at least Python3.5. 42Please note that mat2 requires at least Python3.5.
43 43
44# Requirements setup on macOS (OS X) using [Homebrew](https://brew.sh/)
45
46```bash
47brew install exiftool cairo pygobject3 poppler gdk-pixbuf librsvg ffmpeg
48```
49
44# Running the test suite 50# Running the test suite
45 51
46```bash 52```bash
diff --git a/libmat2/bubblewrap.py b/libmat2/bubblewrap.py
index 7a70635..8033d0a 100644
--- a/libmat2/bubblewrap.py
+++ b/libmat2/bubblewrap.py
@@ -22,10 +22,9 @@ CalledProcessError = subprocess.CalledProcessError
22 22
23 23
24def _get_bwrap_path() -> str: 24def _get_bwrap_path() -> str:
25 bwrap_path = '/usr/bin/bwrap' 25 which_path = shutil.which('bwrap')
26 if os.path.isfile(bwrap_path): 26 if which_path:
27 if os.access(bwrap_path, os.X_OK): 27 return which_path
28 return bwrap_path
29 28
30 raise RuntimeError("Unable to find bwrap") # pragma: no cover 29 raise RuntimeError("Unable to find bwrap") # pragma: no cover
31 30
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")
diff --git a/libmat2/video.py b/libmat2/video.py
index 2b33bc0..b4a3232 100644
--- a/libmat2/video.py
+++ b/libmat2/video.py
@@ -1,6 +1,6 @@
1import subprocess 1import subprocess
2import functools 2import functools
3import os 3import shutil
4import logging 4import logging
5 5
6from typing import Dict, Union 6from typing import Dict, Union
@@ -137,9 +137,8 @@ class MP4Parser(AbstractFFmpegParser):
137 137
138@functools.lru_cache() 138@functools.lru_cache()
139def _get_ffmpeg_path() -> str: # pragma: no cover 139def _get_ffmpeg_path() -> str: # pragma: no cover
140 ffmpeg_path = '/usr/bin/ffmpeg' 140 which_path = shutil.which('ffmpeg')
141 if os.path.isfile(ffmpeg_path): 141 if which_path:
142 if os.access(ffmpeg_path, os.X_OK): 142 return which_path
143 return ffmpeg_path
144 143
145 raise RuntimeError("Unable to find ffmpeg") 144 raise RuntimeError("Unable to find ffmpeg")