1
0
Fork 0

Add which pathfinding for executables

This commit is contained in:
tguinot 2020-02-10 03:31:07 +01:00 committed by jvoisin
parent 12f23e0150
commit 56d2c4aa5f
4 changed files with 20 additions and 17 deletions

View File

@ -41,6 +41,12 @@ Nautilus, the default file manager of GNOME.
Please note that mat2 requires at least Python3.5. Please note that mat2 requires at least Python3.5.
# Requirements setup on macOS (OS X) using [Homebrew](https://brew.sh/)
```bash
brew install exiftool cairo pygobject3 poppler gdk-pixbuf librsvg ffmpeg
```
# Running the test suite # Running the test suite
```bash ```bash

View File

@ -22,10 +22,9 @@ CalledProcessError = subprocess.CalledProcessError
def _get_bwrap_path() -> str: def _get_bwrap_path() -> str:
bwrap_path = '/usr/bin/bwrap' which_path = shutil.which('bwrap')
if os.path.isfile(bwrap_path): if which_path:
if os.access(bwrap_path, os.X_OK): return which_path
return bwrap_path
raise RuntimeError("Unable to find bwrap") # pragma: no cover raise RuntimeError("Unable to find bwrap") # pragma: no cover

View File

@ -2,6 +2,7 @@ import functools
import json import json
import logging import logging
import os import os
import shutil
import subprocess import subprocess
from typing import Dict, Union, Set from typing import Dict, Union, Set
@ -71,14 +72,12 @@ class ExiftoolParser(abstract.AbstractParser):
@functools.lru_cache() @functools.lru_cache()
def _get_exiftool_path() -> str: # pragma: no cover def _get_exiftool_path() -> str: # pragma: no cover
possible_pathes = { which_path = shutil.which('exiftool')
'/usr/bin/exiftool', # debian/fedora if which_path:
'/usr/bin/vendor_perl/exiftool', # archlinux return which_path
}
for possible_path in possible_pathes: # Exiftool on Arch Linux has a weird path
if os.path.isfile(possible_path): if os.access('/usr/bin/vendor_perl/exiftool', os.X_OK):
if os.access(possible_path, os.X_OK): return '/usr/bin/vendor_perl/exiftool'
return possible_path
raise RuntimeError("Unable to find exiftool") raise RuntimeError("Unable to find exiftool")

View File

@ -1,6 +1,6 @@
import subprocess import subprocess
import functools import functools
import os import shutil
import logging import logging
from typing import Dict, Union from typing import Dict, Union
@ -137,9 +137,8 @@ class MP4Parser(AbstractFFmpegParser):
@functools.lru_cache() @functools.lru_cache()
def _get_ffmpeg_path() -> str: # pragma: no cover def _get_ffmpeg_path() -> str: # pragma: no cover
ffmpeg_path = '/usr/bin/ffmpeg' which_path = shutil.which('ffmpeg')
if os.path.isfile(ffmpeg_path): if which_path:
if os.access(ffmpeg_path, os.X_OK): return which_path
return ffmpeg_path
raise RuntimeError("Unable to find ffmpeg") raise RuntimeError("Unable to find ffmpeg")