1
0
Fork 0

Improve the reliability of Exiftool-base parsers

This commit is contained in:
jvoisin 2019-12-15 09:04:51 -08:00
parent 2e3496d3d4
commit f5aef1b391
1 changed files with 12 additions and 7 deletions

View File

@ -20,13 +20,18 @@ class ExiftoolParser(abstract.AbstractParser):
meta_allowlist = set() # type: Set[str]
def get_meta(self) -> Dict[str, Union[str, dict]]:
if self.sandbox:
out = bubblewrap.run([_get_exiftool_path(), '-json', self.filename],
input_filename=self.filename,
check=True, stdout=subprocess.PIPE).stdout
else:
out = subprocess.run([_get_exiftool_path(), '-json', self.filename],
check=True, stdout=subprocess.PIPE).stdout
try:
if self.sandbox:
out = bubblewrap.run([_get_exiftool_path(), '-json',
self.filename],
input_filename=self.filename,
check=True, stdout=subprocess.PIPE).stdout
else:
out = subprocess.run([_get_exiftool_path(), '-json',
self.filename],
check=True, stdout=subprocess.PIPE).stdout
except subprocess.CalledProcessError: # pragma: no cover
raise ValueError
meta = json.loads(out.decode('utf-8'))[0]
for key in self.meta_allowlist:
meta.pop(key, None)