-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloading.py
More file actions
88 lines (81 loc) · 1.98 KB
/
loading.py
File metadata and controls
88 lines (81 loc) · 1.98 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#count=50
#while count >= 0:
# print("#")
import time
import sys
import os
#os.system('clear')
#done = 'false'
#here is the animation
#def animate():
# while done == 'false':
# print('
import random
#animate()
#count=10
#while count >= 0:
#print('Loading:#')
#time.sleep(0.1)
#print('Loading:##',)
#time.sleep(0.1)
#print('Loading:###',)
#time.sleep(0.1)
#print('Loading:####',)
#time.sleep(0.1)
#print('Loading:#####')
#time.sleep(0.1)
#print('Loading:######')
#time.sleep(0.1)
#print('Loading:#######')
#time.sleep(0.1)
#print('Loading:########')
#time.sleep(0.1)
#print('Loading:#########')
#time.sleep(0.1)
#print('Loading:##########')
#time.sleep(0.1)
#print('Loading:###########')
#time.sleep(0.1)
#print('Loading:############')
#time.sleep(0.1)
##count=count-1
# update_progress() : Displays or updates a console progress bar
## Accepts a float between 0 and 1. Any int will be converted to a float.
## A value under 0 represents a 'halt'.
## A value at 1 or bigger represents 100%
def update_progress(progress):
barLength = 50 # Modify this to change the length of the progress bar
status = ""
if isinstance(progress, int):
progress = float(progress)
if not isinstance(progress, float):
progress = 0
status = "error: progress var must be float\r\n"
if progress < 0:
progress = 0
status = "Halt...\r\n"
if progress >= 1:
progress = 1
status = "Done\r\n"
block = int(round(barLength*progress))
text = "\rPercent: [{0}] {1}% {2}".format( "#"*block + "-"*(barLength-block), progress*100, status)
sys.stdout.write(text)
sys.stdout.flush()
# update_progress test script
count =10
def loading(count):
delay=random.uniform(.005,.05)
print ""
print "progress :package",10-count+1
for i in range(101):
time.sleep(delay)
update_progress(i/100.0)
while count>0:
loading(count)
count=count-1
delay=random.uniform(.1,1)
time.sleep(delay)
print ""
print "Test completed"
time.sleep(1)
#long process here