Enhance error handling in exiftool and pngcheck analyzers

This commit is contained in:
Zeecka
2025-12-28 17:44:13 +01:00
parent db212312e7
commit ac07266bff
2 changed files with 25 additions and 9 deletions
+12 -9
View File
@@ -18,21 +18,24 @@ def analyze_exiftool(input_img: Path, output_dir: Path) -> None:
timeout=MAX_PENDING_TIME, timeout=MAX_PENDING_TIME,
) )
if data.stderr:
update_data(
output_dir, {"exiftool": {"status": "error", "error": data.stderr}}
)
return
metadata: dict[str, str] = {} metadata: dict[str, str] = {}
for line in data.stdout.split("\n"): for line in data.stdout.split("\n"):
if ":" in line: if ":" in line:
key, value = line.split(":", 1) key, value = line.split(":", 1)
metadata[key.strip()] = value.strip() metadata[key.strip()] = value.strip()
# exiftool_dir = output_dir / "exiftool" if data.stderr:
# exiftool_dir.mkdir(parents=True, exist_ok=True) update_data(
# update_data(exiftool_dir, metadata, "data.json") output_dir,
{
"exiftool": {
"status": "error",
"output": metadata,
"error": data.stderr,
}
},
)
return
update_data( update_data(
output_dir, output_dir,
+13
View File
@@ -24,6 +24,19 @@ def analyze_pngcheck(input_img: Path, output_dir: Path) -> None:
# ) # )
# return # return
if "this is neither a PNG or JNG image nor a MNG stream" in data.stdout:
update_data(
output_dir,
{
"pngcheck": {
"status": "error",
"error": "ERRORS DETECTED: this is neither a PNG or JNG image nor a "
"MNG stream.",
}
},
)
return
data_pngcheck = data.stdout.split("\n") if data else [] data_pngcheck = data.stdout.split("\n") if data else []
data_pngcheck = [s for s in data_pngcheck if s] data_pngcheck = [s for s in data_pngcheck if s]