slotUI/logger.py

Fri, 27 Dec 2013 11:56:22 +0100

author
mbayer
date
Fri, 27 Dec 2013 11:56:22 +0100
changeset 154
46822de910ff
parent 137
94d71156517b
permissions
-rw-r--r--

addedd car activity packet to receiver in car firmware

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