slotUI/logger.py

Mon, 23 Dec 2013 10:59:14 +0100

author
mbayer
date
Mon, 23 Dec 2013 10:59:14 +0100
changeset 151
0e71b51c83a5
parent 137
94d71156517b
permissions
-rw-r--r--

car: finished set_id function

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

mercurial