From 2e337ff079c1f85e32845e6a10ef9956a3a23a7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastjan=20Arti=C4=8D?= Date: Tue, 28 Apr 2026 16:22:39 +0000 Subject: [PATCH] Fix: shutil import was inside finally block, causing NameError when shutil.move was called --- app/main.py | 7 ++++++- scripts/clip.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index 9c98533..76d407b 100644 --- a/app/main.py +++ b/app/main.py @@ -119,12 +119,17 @@ def run_subprocess_logged(cmd, job_id, step_name): update_job(job_id, current_step=step_name, status="processing") proc = subprocess.run(cmd, capture_output=True, text=True) if proc.returncode != 0: + # Combine stdout + stderr za diagnostiko + err_msg = (proc.stderr or "") + "\n" + (proc.stdout or "") update_job( job_id, status="failed", - error=f"{step_name}: {proc.stderr[-500:]}", + error=f"{step_name}: {err_msg[-800:].strip()}", ) return False + # Tudi pri success-u beleži stderr za diagnostiko (samo zadnji del) + if proc.stderr and proc.stderr.strip(): + update_job(job_id, last_step_log=proc.stderr[-500:].strip()) return True diff --git a/scripts/clip.py b/scripts/clip.py index e112dec..7ff2829 100644 --- a/scripts/clip.py +++ b/scripts/clip.py @@ -13,6 +13,7 @@ Primer: python3 clip.py input.mp4 out_dir/ --clips "0:30-1:00,2:15-2:45,5:00-5:30" --lang sl """ import argparse +import shutil import subprocess import sys import os @@ -85,7 +86,6 @@ def run_clip(src, dst, start, duration, mode, lang, model, style, no_subs, quali shutil.move(str(reframed), str(dst)) return True finally: - import shutil shutil.rmtree(tmp, ignore_errors=True)