Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Console progress bar -- takes stdin from arbitrary commands and plots a progress bar
"""
SYNOPSIS: ./myprog | python console-progress.py
example for myprog:
#!/bin/bash
echo 100
for i in $(seq 1 100)
do
sleep 1
echo $i
done
"""
import progressbar
import sys
end = sys.stdin.readline()
pbar = progressbar.ProgressBar(
widgets=[progressbar.Percentage(), progressbar.Counter('%5d'), progressbar.Bar(), progressbar.ETA()],
maxval=float(end)).start()
while True:
current = sys.stdin.readline()
if current is None:
break
pbar.update(float(current))
pbar.finish()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.