From 577308af17df088e7fd939ee17db0d18990a9a9f Mon Sep 17 00:00:00 2001 From: Louis Labeyrie Date: Thu, 19 Mar 2026 19:12:29 +0100 Subject: [PATCH] fix: extract image path from prefixed stdout line _extract_image_from_stdout() failed to find the generated image because the pipeline prints "Card generated and saved to: generated_card.png" but the function only tried the full line as a path. Now also tries the part after the last colon. --- app.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/app.py b/app.py index 0324803..0b4b828 100644 --- a/app.py +++ b/app.py @@ -16,16 +16,21 @@ IMAGE_EXTENSIONS = (".png", ".jpg", ".jpeg", ".webp", ".bmp") def _extract_image_from_stdout(stdout: str) -> Path | None: for line in reversed(stdout.splitlines()): - text = line.strip().strip("\"'") - if not text: - continue + # Try the whole line, then the part after the last colon + # (handles "Card generated and saved to: generated_card.png") + raw = line.strip().strip("\"'") + candidates = [raw] + if ":" in raw: + candidates.append(raw.rsplit(":", 1)[1].strip().strip("\"'")) - candidate = Path(text) - if not candidate.is_absolute(): - candidate = APP_DIR / candidate - - if candidate.suffix.lower() in IMAGE_EXTENSIONS and candidate.exists(): - return candidate + for text in candidates: + if not text: + continue + candidate = Path(text) + if not candidate.is_absolute(): + candidate = APP_DIR / candidate + if candidate.suffix.lower() in IMAGE_EXTENSIONS and candidate.exists(): + return candidate return None