slotUI/logger.py

changeset 137
94d71156517b
equal deleted inserted replaced
136:e7336e63acf6 137:94d71156517b
1 class eventLogger:
2 def __init__(self, filename):
3 self.filename = filename
4
5 def push(self, data):
6 """Pushes data to logfile CSV output:
7 struc:
8 unix timestamp
9 system clock
10 rennbezeichnung
11 slot
12 slotname (player)
13 runde
14 letzte rundenzeit
15 beste rundenzeit
16 laplimit
17 timelimit
18 """
19 try:
20 fd = open(self.filename, 'a')
21 ok = True
22 except:
23 ok = False
24 if not ok:
25 fd = open(self.filename, 'w')
26 if ok:
27 fd.write("%s;%s;\"%s\";%s;\"%s\";%s;%s;%s;%s;%s\n" % (
28 data[0],
29 data[1],
30 data[2],
31 data[3],
32 data[4],
33 data[5],
34 data[6],
35 data[7],
36 data[8],
37 data[9]
38 ))
39 fd.close()
40

mercurial