diff options
| -rw-r--r-- | .gitlab-ci.yml | 7 | ||||
| -rw-r--r-- | libmat2/__init__.py | 21 | ||||
| -rw-r--r-- | libmat2/images.py | 4 |
3 files changed, 25 insertions, 7 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0d8d0ee..cd64b42 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml | |||
| @@ -53,3 +53,10 @@ tests:fedora: | |||
| 53 | - dnf install -y python3 python3-mutagen python3-gobject gdk-pixbuf2 poppler-glib gdk-pixbuf2 gdk-pixbuf2-modules cairo-gobject cairo python3-cairo perl-Image-ExifTool mailcap | 53 | - dnf install -y python3 python3-mutagen python3-gobject gdk-pixbuf2 poppler-glib gdk-pixbuf2 gdk-pixbuf2-modules cairo-gobject cairo python3-cairo perl-Image-ExifTool mailcap |
| 54 | - gdk-pixbuf-query-loaders-64 > /usr/lib64/gdk-pixbuf-2.0/2.10.0/loaders.cache | 54 | - gdk-pixbuf-query-loaders-64 > /usr/lib64/gdk-pixbuf-2.0/2.10.0/loaders.cache |
| 55 | - python3 setup.py test | 55 | - python3 setup.py test |
| 56 | |||
| 57 | tests:archlinux: | ||
| 58 | image: archlinux/base | ||
| 59 | stage: test | ||
| 60 | script: | ||
| 61 | - pacman -Sy --noconfirm python-mutagen python-gobject gdk-pixbuf2 poppler-glib gdk-pixbuf2 python-cairo perl-image-exiftool python-setuptools mailcap | ||
| 62 | - python3 setup.py test | ||
diff --git a/libmat2/__init__.py b/libmat2/__init__.py index 6072b42..6067861 100644 --- a/libmat2/__init__.py +++ b/libmat2/__init__.py | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | import os | 3 | import os |
| 4 | import collections | 4 | import collections |
| 5 | import importlib | 5 | import importlib |
| 6 | from typing import Dict | 6 | from typing import Dict, Optional |
| 7 | 7 | ||
| 8 | # make pyflakes happy | 8 | # make pyflakes happy |
| 9 | assert Dict | 9 | assert Dict |
| @@ -35,13 +35,24 @@ DEPENDENCIES = { | |||
| 35 | 'mutagen': 'Mutagen', | 35 | 'mutagen': 'Mutagen', |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | def _get_exiftool_path() -> Optional[str]: | ||
| 39 | exiftool_path = '/usr/bin/exiftool' | ||
| 40 | if os.path.isfile(exiftool_path): | ||
| 41 | if os.access(exiftool_path, os.X_OK): # pragma: no cover | ||
| 42 | return exiftool_path | ||
| 43 | |||
| 44 | # ArchLinux | ||
| 45 | exiftool_path = '/usr/bin/vendor_perl/exiftool' | ||
| 46 | if os.path.isfile(exiftool_path): | ||
| 47 | if os.access(exiftool_path, os.X_OK): # pragma: no cover | ||
| 48 | return exiftool_path | ||
| 49 | |||
| 50 | return None | ||
| 51 | |||
| 38 | def check_dependencies() -> dict: | 52 | def check_dependencies() -> dict: |
| 39 | ret = collections.defaultdict(bool) # type: Dict[str, bool] | 53 | ret = collections.defaultdict(bool) # type: Dict[str, bool] |
| 40 | 54 | ||
| 41 | exiftool = '/usr/bin/exiftool' | 55 | ret['Exiftool'] = True if _get_exiftool_path() else False |
| 42 | ret['Exiftool'] = False | ||
| 43 | if os.path.isfile(exiftool) and os.access(exiftool, os.X_OK): # pragma: no cover | ||
| 44 | ret['Exiftool'] = True | ||
| 45 | 56 | ||
| 46 | for key, value in DEPENDENCIES.items(): | 57 | for key, value in DEPENDENCIES.items(): |
| 47 | ret[value] = True | 58 | ret[value] = True |
diff --git a/libmat2/images.py b/libmat2/images.py index faa93a4..837f015 100644 --- a/libmat2/images.py +++ b/libmat2/images.py | |||
| @@ -13,7 +13,7 @@ import gi | |||
| 13 | gi.require_version('GdkPixbuf', '2.0') | 13 | gi.require_version('GdkPixbuf', '2.0') |
| 14 | from gi.repository import GdkPixbuf | 14 | from gi.repository import GdkPixbuf |
| 15 | 15 | ||
| 16 | from . import abstract | 16 | from . import abstract, _get_exiftool_path |
| 17 | 17 | ||
| 18 | # Make pyflakes happy | 18 | # Make pyflakes happy |
| 19 | assert Set | 19 | assert Set |
| @@ -40,7 +40,7 @@ class _ImageParser(abstract.AbstractParser): | |||
| 40 | self.filename to prevent parameter injections, so we need to take care | 40 | self.filename to prevent parameter injections, so we need to take care |
| 41 | of this. | 41 | of this. |
| 42 | """ | 42 | """ |
| 43 | fun = lambda f: subprocess.check_output(['/usr/bin/exiftool', '-json', f]) | 43 | fun = lambda f: subprocess.check_output([_get_exiftool_path(), '-json', f]) |
| 44 | if re.search('^[a-z0-9/]', self.filename) is None: | 44 | if re.search('^[a-z0-9/]', self.filename) is None: |
| 45 | out = self.__handle_problematic_filename(self.filename, fun) | 45 | out = self.__handle_problematic_filename(self.filename, fun) |
| 46 | else: | 46 | else: |
