/
testClients.py
51 lines (40 loc) · 1.09 KB
/
testClients.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
#!/usr/bin/env python
# _*_ coding: UTF-8 _*_
import pylan
import pylanrc
import time
workdir = pylanrc.get_workdir()
class TestClients:
def __init__(self,numtest,time):
self.numtest = numtest
self.time = time
def print_args(self):
print self.numtest
print self.time
def run_sessions(self):
for seasson in xrange(self.numtest):
print "#"*10+" Teste numero: "+str(seasson+1)+" "+"#"*10
for i in xrange(int(self.time)*60):
for j in pylan.maquinas:
fd = open(workdir+j[3],'w')
fd.write(str((self.time*60)-i-1))
fd.close()
print workdir+j[3]+" "+sec2beauty((self.time*60)-i-1)
time.sleep(1)
def sec2beauty(hud):
hor = str(hud/3600)
min = str((hud%3600)/60)
seg = str((hud%3600)%60)
hud = str(n(hor)+':'+n(min)+':'+n(seg))
return hud
def n(var):
""" Recebe um número com um digito e retorna o mesmo numero com um zero na frente """
if len(var) < 2:
return '0'+var
else:
return var
def main():
w = TestClients(3,1)
w.run_sessions()
if __name__ == '__main__':
main()