Commit f5aef1b3 authored by jvoisin's avatar jvoisin
Browse files

Improve the reliability of Exiftool-base parsers

parent 2e3496d3
Pipeline #31821 passed with stages
in 2 minutes and 8 seconds
...@@ -20,13 +20,18 @@ class ExiftoolParser(abstract.AbstractParser): ...@@ -20,13 +20,18 @@ class ExiftoolParser(abstract.AbstractParser):
meta_allowlist = set() # type: Set[str] meta_allowlist = set() # type: Set[str]
def get_meta(self) -> Dict[str, Union[str, dict]]: def get_meta(self) -> Dict[str, Union[str, dict]]:
if self.sandbox: try:
out =[_get_exiftool_path(), '-json', self.filename], if self.sandbox:
input_filename=self.filename, out =[_get_exiftool_path(), '-json',
check=True, stdout=subprocess.PIPE).stdout self.filename],
else: input_filename=self.filename,
out =[_get_exiftool_path(), '-json', self.filename], check=True, stdout=subprocess.PIPE).stdout
check=True, stdout=subprocess.PIPE).stdout else:
out =[_get_exiftool_path(), '-json',
check=True, stdout=subprocess.PIPE).stdout
except subprocess.CalledProcessError: # pragma: no cover
raise ValueError
meta = json.loads(out.decode('utf-8'))[0] meta = json.loads(out.decode('utf-8'))[0]
for key in self.meta_allowlist: for key in self.meta_allowlist:
meta.pop(key, None) meta.pop(key, None)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment