Skip to content

Instantly share code, notes, and snippets.

@JohannesBuchner JohannesBuchner/
Last active Dec 27, 2015

What would you like to do?
ETA from external programs
"""Estimate Time until completion of a process.
Usage: <statusprog> | <n>
<statusprog> is a program that writes a line to stdout from time to time.
The line is the number of items completed so far.
<n> is the total number of items to complete.
for((i=0;i<20;i++)); do echo $i; sleep 1; done | python 20
Author: Johannes Buchner (C) 2013
import sys
import progressbar
if len(sys.argv) < 2:
n = int(sys.argv[1])
k = int(sys.stdin.readline())
m = n - k
print 'starting with {} of {} done. {} left'.format(k, n, m)
if m > 0:
pbar = progressbar.ProgressBar(
widgets=[progressbar.Percentage(), progressbar.Counter('%5d'),
progressbar.Bar(), progressbar.ETA()],
while True:
l = sys.stdin.readline()
if l == '': break
l = int(l)
pbar.update(l - k)
if l == m:
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.