From 1dd39c08dbb133c47b254fd9d80b84fd7a036150 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 22 Oct 2026 08:37:21 +0200 Subject: [PATCH] Downloads: Fortschritt alle 30 s im Log Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01X48pE4bzjHej8w9HyZXCjb --- trainpulse/prepare.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/trainpulse/prepare.py b/trainpulse/prepare.py index e0dfb99..5ddeef4 100644 --- a/trainpulse/prepare.py +++ b/trainpulse/prepare.py @@ -54,9 +54,14 @@ def download(url: str, dest: Path) -> None: with httpx.stream("GET", url, follow_redirects=True, timeout=120, headers={"User-Agent": C.USER_AGENT}) as r: r.raise_for_status() + total, done, t0, last = int(r.headers.get("content-length", 0)), 0, time.time(), time.time() with open(tmp, "wb") as f: for chunk in r.iter_bytes(1 << 20): f.write(chunk) + done += len(chunk) + if time.time() - last > 30: # Fortschritt, damit ein langsamer Download nicht wie ein Hänger aussieht + last = time.time() + log.info(" … %d von %d MB (%.1f MB/s)", done >> 20, total >> 20, done / (last - t0) / 1e6) tmp.rename(dest)