fix: broken subprocess command and tuple unpacking in app.py #19
11
app.py
11
app.py
@@ -16,14 +16,19 @@ IMAGE_EXTENSIONS = (".png", ".jpg", ".jpeg", ".webp", ".bmp")
|
|||||||
|
|
||||||
def _extract_image_from_stdout(stdout: str) -> Path | None:
|
def _extract_image_from_stdout(stdout: str) -> Path | None:
|
||||||
for line in reversed(stdout.splitlines()):
|
for line in reversed(stdout.splitlines()):
|
||||||
text = line.strip().strip("\"'")
|
# 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("\"'"))
|
||||||
|
|
||||||
|
for text in candidates:
|
||||||
if not text:
|
if not text:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
candidate = Path(text)
|
candidate = Path(text)
|
||||||
if not candidate.is_absolute():
|
if not candidate.is_absolute():
|
||||||
candidate = APP_DIR / candidate
|
candidate = APP_DIR / candidate
|
||||||
|
|
||||||
if candidate.suffix.lower() in IMAGE_EXTENSIONS and candidate.exists():
|
if candidate.suffix.lower() in IMAGE_EXTENSIONS and candidate.exists():
|
||||||
return candidate
|
return candidate
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user