Fix: shutil import was inside finally block, causing NameError when shutil.move was called

This commit is contained in:
Sebastjan Artič 2026-04-28 16:22:39 +00:00
parent c34e4aa376
commit 2e337ff079
2 changed files with 7 additions and 2 deletions

View File

@ -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

View File

@ -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)