From e8c1bb0e3c4cae579e81ce6a4b01b829900ff922 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Sun, 3 Feb 2019 09:43:27 +0000 Subject: Whenever possible, use bwrap for subprocesses This should closes #90 --- libmat2/exiftool.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'libmat2/exiftool.py') diff --git a/libmat2/exiftool.py b/libmat2/exiftool.py index adec28e..db92f60 100644 --- a/libmat2/exiftool.py +++ b/libmat2/exiftool.py @@ -1,10 +1,10 @@ import json import logging import os -import subprocess from typing import Dict, Union, Set from . import abstract +from . import subprocess # Make pyflakes happy assert Set @@ -18,7 +18,9 @@ class ExiftoolParser(abstract.AbstractParser): meta_whitelist = set() # type: Set[str] def get_meta(self) -> Dict[str, Union[str, dict]]: - out = subprocess.check_output([_get_exiftool_path(), '-json', self.filename]) + out = subprocess.run([_get_exiftool_path(), '-json', self.filename], + input_filename=self.filename, + check=True, stdout=subprocess.PIPE).stdout meta = json.loads(out.decode('utf-8'))[0] for key in self.meta_whitelist: meta.pop(key, None) @@ -46,7 +48,9 @@ class ExiftoolParser(abstract.AbstractParser): '-o', self.output_filename, self.filename] try: - subprocess.check_call(cmd) + subprocess.run(cmd, check=True, + input_filename=self.filename, + output_filename=self.output_filename) except subprocess.CalledProcessError as e: # pragma: no cover logging.error("Something went wrong during the processing of %s: %s", self.filename, e) return False -- cgit v1.3