slotUI/logger.py

Mon, 23 Dec 2013 14:05:53 +0100

author
mbayer
date
Mon, 23 Dec 2013 14:05:53 +0100
changeset 152
e787f47c084b
parent 137
94d71156517b
permissions
-rw-r--r--

finished car id programming and brake function

class eventLogger:
    def __init__(self, filename):
        self.filename = filename

    def push(self, data):
        """Pushes data to logfile CSV output:
        struc:
            unix timestamp
            system clock
            rennbezeichnung
            slot
            slotname (player)
            runde
            letzte rundenzeit
            beste rundenzeit
            laplimit
            timelimit
        """
        try:
            fd = open(self.filename, 'a')
            ok = True
        except:
            ok = False
        if not ok:
            fd = open(self.filename, 'w')
        if ok:
            fd.write("%s;%s;\"%s\";%s;\"%s\";%s;%s;%s;%s;%s\n" % (
                data[0],
                data[1],
                data[2],
                data[3],
                data[4],
                data[5],
                data[6],
                data[7],
                data[8],
                data[9]
                ))
            fd.close()

mercurial