diff options
| author | jvoisin | 2019-12-15 09:04:51 -0800 |
|---|---|---|
| committer | jvoisin | 2019-12-15 09:04:51 -0800 |
| commit | f5aef1b391e8c112543a6cebe50e8397b1daf3ca (patch) | |
| tree | aedfc92e968237b3bb767eb24905a2410e086dbb /libmat2/exiftool.py | |
| parent | 2e3496d3d49776a83b35e5f72ef50a642f350f58 (diff) | |
Improve the reliability of Exiftool-base parsers
Diffstat (limited to '')
| -rw-r--r-- | libmat2/exiftool.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/libmat2/exiftool.py b/libmat2/exiftool.py index 89081e2..1ce60a1 100644 --- a/libmat2/exiftool.py +++ b/libmat2/exiftool.py | |||
| @@ -20,13 +20,18 @@ class ExiftoolParser(abstract.AbstractParser): | |||
| 20 | meta_allowlist = set() # type: Set[str] | 20 | meta_allowlist = set() # type: Set[str] |
| 21 | 21 | ||
| 22 | def get_meta(self) -> Dict[str, Union[str, dict]]: | 22 | def get_meta(self) -> Dict[str, Union[str, dict]]: |
| 23 | if self.sandbox: | 23 | try: |
| 24 | out = bubblewrap.run([_get_exiftool_path(), '-json', self.filename], | 24 | if self.sandbox: |
| 25 | input_filename=self.filename, | 25 | out = bubblewrap.run([_get_exiftool_path(), '-json', |
| 26 | check=True, stdout=subprocess.PIPE).stdout | 26 | self.filename], |
| 27 | else: | 27 | input_filename=self.filename, |
| 28 | out = subprocess.run([_get_exiftool_path(), '-json', self.filename], | 28 | check=True, stdout=subprocess.PIPE).stdout |
| 29 | check=True, stdout=subprocess.PIPE).stdout | 29 | else: |
| 30 | out = subprocess.run([_get_exiftool_path(), '-json', | ||
| 31 | self.filename], | ||
| 32 | check=True, stdout=subprocess.PIPE).stdout | ||
| 33 | except subprocess.CalledProcessError: # pragma: no cover | ||
| 34 | raise ValueError | ||
| 30 | meta = json.loads(out.decode('utf-8'))[0] | 35 | meta = json.loads(out.decode('utf-8'))[0] |
| 31 | for key in self.meta_allowlist: | 36 | for key in self.meta_allowlist: |
| 32 | meta.pop(key, None) | 37 | meta.pop(key, None) |
