forked from enormandeau/Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
progress_bar.py
executable file
·55 lines (41 loc) · 1.27 KB
/
progress_bar.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python
"""Print a progress bar given a total and a current progress
USAGE:
%program total progress
EXAMPLE:
progress_bar.py 30 18 [name of process]
gives:
process_name number_done: 3/30 (=== ) 10.0%
"""
import sys
import math
try:
number_total = int(sys.argv[1])
number_done = int(sys.argv[2])
except:
print __doc__
sys.exit(1)
try:
process_name = sys.argv[3]
except:
process_name = "progress"
try:
percent_done = 100. * number_done / number_total
except:
percent_done = 0
name = process_name + ": "
name = name + (16 - len(name)) * " "
numbers = str(number_done) + "/" + str(number_total) + " "
numbers = numbers + (8 - len(numbers)) * " "
progress = int(math.floor(percent_done * 0.3)) * "="
progress = progress + (30 - len(progress)) * " "
progress = "(" + progress + ") "
percent = str("%3.1f" % percent_done) + "%"
print name + numbers + progress + percent
"""
Processes:
sai: 60/60 (==================================================) 100.0%
sam: 60/60 (==================================================) 100.0%
STACKS_fq1: 10/30 (================ ) 33.3%
STACKS_fq1: 3/30 (===== ) 10.0%
"""