don't crash on stalls
This commit is contained in:
parent
af7bb62a13
commit
465fb2ba5d
20
impatient
20
impatient
|
@ -3,6 +3,7 @@
|
||||||
import argparse
|
import argparse
|
||||||
import datetime
|
import datetime
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
WINDOW_SIZE = 100
|
WINDOW_SIZE = 100
|
||||||
|
@ -72,18 +73,19 @@ while True:
|
||||||
rate = (current - samples[0])/((len(samples)-1)*args.interval)
|
rate = (current - samples[0])/((len(samples)-1)*args.interval)
|
||||||
|
|
||||||
print('\033[2K\r', end='')
|
print('\033[2K\r', end='')
|
||||||
print('{} - {}/s'.format(display_value(current), display_value(rate)), end='', flush=True)
|
print('{} - {}/s'.format(display_value(current), display_value(rate)), end='')
|
||||||
if final:
|
if final:
|
||||||
fraction = current / final
|
fraction = current / final
|
||||||
value_remaining = final - current
|
value_remaining = final - current
|
||||||
time_remaining = datetime.timedelta(seconds=(value_remaining / rate))
|
print(' - {} total - {:.1f}% complete'.format(display_value(final), 100*fraction), end='')
|
||||||
eta = datetime.datetime.now() + time_remaining
|
if rate > 0:
|
||||||
print(' - {} total - {:.1f}% complete - {} remaining - ETA {}'.format(
|
time_remaining = datetime.timedelta(seconds=(value_remaining / rate))
|
||||||
display_value(final),
|
eta = datetime.datetime.now() + time_remaining
|
||||||
100*fraction,
|
print(' - {} remaining - ETA {}'.format(
|
||||||
display_timedelta(time_remaining),
|
display_timedelta(time_remaining),
|
||||||
eta.isoformat(sep=' ', timespec='minutes'),
|
eta.isoformat(sep=' ', timespec='minutes'),
|
||||||
), end='', flush=True)
|
), end='')
|
||||||
|
sys.stdout.flush()
|
||||||
|
|
||||||
if final and current >= final:
|
if final and current >= final:
|
||||||
print()
|
print()
|
||||||
|
|
Loading…
Reference in a new issue