-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimeTools.py
More file actions
32 lines (28 loc) · 1.16 KB
/
Copy pathtimeTools.py
File metadata and controls
32 lines (28 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import datetime
import sys
import time
"""
includes tools that display time taken and expected finishing time of a loop
being run using printTimeDetails which takes input for i (current loop) n
(final loop) and st(starting time using time.time() before the loop started
"""
def printTimeDetails(i, n, st):
dt = time.time()-st
sys.stdout.write(str(round(float(i)/n * 100, 3))
+ '% complete | Elapsed: '
+ str(datetime.timedelta(seconds=round(dt)))
+ ' | ETA: '
+ str(datetime.timedelta(seconds=(round(dt*n/float(i))
- round(dt))))
+ ' \r')
sys.stdout.flush()
def loadingBar(i, n):
# will use 40 '=' signs to display progress through a loop
percent = float(i) / n * 100
numbEquals = int(percent*.4)
if(i != (n-1)):
sys.stdout.write('[' + numbEquals * '=' + ' ' * (40-numbEquals)
+ ']' + str(round(percent, 4)) + '% complete'
+ ' \r')
else:
sys.stdout.write('['+40*'='+'] Done'+' \r')