-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogger.py
53 lines (38 loc) · 1.44 KB
/
Logger.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
import os, sys, time
total_t = 10
case = ['Clean']
outDir = '/Users/scamarlinghi/workspace/Siri_WakeupTest'
siriLog = os.path.join(outDir, 'siriLog.txt')
cmd = 'idevicesyslog >> ' + siriLog
#os.system('idevicesyslog >> '+ outDir + ' siriLog.txt')
os.system(cmd)
class Logger(object):
def __init__(self, filename = 'Default.log'):
self.terminal = sys.stdout
self.log = open(filename, 'a')
def write(self, message):
self.terminal.write(message)
self.log.write(message)
def seraSera(value):
f = os.path.join(outDir, value + '.txt')
print f
sys.stdout = Logger(f)
start_t = time.asctime()
start = time.time()
print "============================================================="
print "\nCase: %s \nStart time: %s " % (value, start_t)
print "============================================================="
while True:
os.system('tail -f /Users/scamarlinghi/workspace/Siri_WakeupTest/siriLog.txt >> ' + f)
#os.system('idevicesyslog -d | grep Siri')
delta_t = time.time() - start
if int(delta_t) >= total_t:
break
print "============================================================="
print "\nCase: %s \nStart time: %s \nEnd time: %s" % (value, start_t, time.asctime())
print "============================================================="
def main():
for value in case:
seraSera(value)
if __name__ == '__main__':
main()