Skip to content

Commit c3ec43f

Browse files
committed
fix: only print progress if totel_jops > 0
1 parent 2503762 commit c3ec43f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

ptop.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ def progress(lines, total_jops):
4242
return (len(lines) / tj) * 100 if tj else 0
4343

4444

45-
def ascii_progress_bar(percentage, total_jobs, bar_length=50):
46-
if total_jobs > 0:
47-
filled_length = int(bar_length * percentage // 100)
48-
bar = "█" * filled_length + "-" * (bar_length - filled_length)
49-
return f"[{bar}] {percentage:.2f}%"
45+
def ascii_progress_bar(percentage, bar_length=50):
46+
filled_length = int(bar_length * percentage // 100)
47+
bar = "█" * filled_length + "-" * (bar_length - filled_length)
48+
return f"[{bar}] {percentage:.2f}%"
49+
5050

5151

5252
try:
@@ -61,7 +61,9 @@ def ascii_progress_bar(percentage, total_jobs, bar_length=50):
6161
lines.extend(new_lines)
6262

6363
clear_console()
64-
print(ascii_progress_bar(progress(lines, tj),tj))
64+
if tj > 0:
65+
print(ascii_progress_bar(progress(lines, tj)))
66+
6567
print(
6668
"--------------------------------------------------------------"
6769
)

0 commit comments

Comments
 (0)