Prettify refresh printout

Make the CR happen at the end of printout instead of the start, so the
cursor doesn't look like it's jumping all over the line.
This commit is contained in:
Jake Bauer 2023-11-02 14:33:28 +01:00
parent bbda9b9ed9
commit 3c12d9894a
1 changed files with 3 additions and 3 deletions

View File

@ -483,19 +483,19 @@ def refresh_feeds():
finished_jobs = 0
start = default_timer()
with ThreadPoolExecutor(max_workers=conf.get_value("threads")) as executor:
print(f"Refreshed 0/{total_jobs} feeds", end="", flush=True)
print(f"Refreshed 0/{total_jobs} feeds\r", end="", flush=True)
for result in executor.map(load_feed, [feed["url"] for feed in feeds]):
if result == 0:
finished_jobs += 1
print(
f"\rRefreshed {finished_jobs}/{total_jobs} feeds",
f"Refreshed {finished_jobs}/{total_jobs} feeds\r",
end="",
flush=True,
)
times = str(dt.timedelta(seconds=round(default_timer() - start))).split(":")[1:]
tot_time = (times[0].lstrip("0") + "m") if int(times[0]) > 0 else ""
tot_time += (times[1].lstrip("0") + "s") if int(times[1]) > 0 else "0s"
print(f" in {tot_time}", end="")
print(f"\nFinished in {tot_time}", end="")
if finished_jobs < total_jobs:
print(f" ({total_jobs - finished_jobs} failed)")
else: