-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalyser
More file actions
executable file
·50 lines (43 loc) · 1.45 KB
/
analyser
File metadata and controls
executable file
·50 lines (43 loc) · 1.45 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
#!/usr/bin/python
import time
def generate(content):
timestamp=content.split('@@')[0].split('@')[1]
# print 'timestamp:\t',"-"+timestamp+"-"
data=content.split('@@')[1]
# print 'data:\t\t',data
status.write(time.strftime('%Y-%m-%d %X',time.localtime(float(timestamp)))+'\n')
pointer=0
for number in data.split():
if pointer >= len(ruler):
return 1
print pointer,number,ruler[pointer]
if int(number)<0:
status_line='<img src="0">'
elif int(number)<int(ruler[pointer][1]):
status_line='<img src="1">'
elif int(number)<int(ruler[pointer][2]):
status_line='<img src="2">'
else:
# status_line='<img src="3"><embed src="alert" width=0 height=0 type="audio/mpeg" loop=1 autostart="true"></embed>'
status_line='<img src="3"><embed src="alert" width=0 height=0 type="audio/mpeg">'
status.write(status_line+ruler[pointer][0]+' : '+number+'\n')
# status.write(str(ruler[pointer])+'\n')
pointer+=1
return 0
log_file='SMART.log'
status_file='SMART.status'
criteria_file='SMART.criteria'
log=open(log_file,'r')
status=open(status_file,'w')
criteria=open(criteria_file,'r')
ruler=[]
for line in criteria.readlines():
rule=line.split('\n')[0]
ruler.append(rule.split())
#print 'ruler:\t\t',ruler
criteria.close
for line in log.readlines():
content=line.split('\n')[0]
generate(content)
log.close
status.close