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