Skip to content

Commit

Permalink
Merge pull request #107 from ns1/get-private-dns-fix-progress-bar-cli…
Browse files Browse the repository at this point in the history
…pping

Fix bug in get_privatedns.py progress bar
  • Loading branch information
lvfrazao authored Apr 5, 2021
2 parents 7865737 + 117ca10 commit 6d4335f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion utils/get_privatedns/get_privatedns.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import os
import json
import argparse
import subprocess
from timeit import default_timer

try:
Expand Down Expand Up @@ -217,13 +218,17 @@ def make_progress_bar(completed, total, rate, complete=False):
bar_size = 56
pct_complete = completed / total
full_bars = int(bar_size * pct_complete)
try:
columns = int(subprocess.check_output(['stty', 'size']).decode().split()[1])
except:
columns = 80
progress_bar = (
"["
+ "#" * full_bars
+ ">"
+ " " * (bar_size - full_bars)
+ "] ({:.2f}%) {}".format(pct_complete * 100, metric_prefix(rate))
)
).ljust(columns)
print("\r", progress_bar, sep="", end="")
if complete:
print()
Expand Down

0 comments on commit 6d4335f

Please sign in to comment.