slotUI/logger.py

Tue, 25 Jun 2013 22:18:17 +0200

author
Malte Bayer <mbayer@neo-soft.org>
date
Tue, 25 Jun 2013 22:18:17 +0200
changeset 138
a570dd24a413
parent 137
94d71156517b
permissions
-rw-r--r--

Added tag FIRMWARE_BEFORE_BINARY_COMMUNICATION for changeset 94d71156517b

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