Exemplo n.º 1
0
                            if brewometerValue is not None:
                                prevTempJson[colour + 'Temp'] = round(brewometerValue.temperature, 2)
                                prevTempJson[colour + 'SG'] = brewometerValue.gravity
                            else:
                                prevTempJson[colour + 'Temp'] = None
                                prevTempJson[colour + 'SG'] = None

                        # process temperature line
                        newData = json.loads(line[2:])
                        # copy/rename keys
                        for key in newData:
                            prevTempJson[renameTempKey(key)] = newData[key]

                        newRow = prevTempJson
                        # add to JSON file
                        brewpiJson.addRow(localJsonFileName, newRow)
                        # copy to www dir.
                        # Do not write directly to www dir to prevent blocking www file.
                        shutil.copyfile(localJsonFileName, wwwJsonFileName)
                        #write csv file too
                        csvFile = open(localCsvFileName, "a")
                        try:
                            lineToWrite = (time.strftime("%b %d %Y %H:%M:%S;") +
                                           json.dumps(newRow['BeerTemp']) + ';' +
                                           json.dumps(newRow['BeerSet']) + ';' +
                                           json.dumps(newRow['BeerAnn']) + ';' +
                                           json.dumps(newRow['FridgeTemp']) + ';' +
                                           json.dumps(newRow['FridgeSet']) + ';' +
                                           json.dumps(newRow['FridgeAnn']) + ';' +
                                           json.dumps(newRow['State']) + ';' +
                                           json.dumps(newRow['RoomTemp']) + ';')
Exemplo n.º 2
0
                        # store time of last new data for interval check
                        prevDataTime = time.time()

                        if config['dataLogging'] == 'paused' or config[
                                'dataLogging'] == 'stopped':
                            continue  # skip if logging is paused or stopped

                        # process temperature line
                        newData = json.loads(line[2:])
                        # copy/rename keys
                        for key in newData:
                            prevTempJson[renameTempKey(key)] = newData[key]

                        newRow = prevTempJson
                        # add to JSON file
                        brewpiJson.addRow(localJsonFileName, newRow)
                        # copy to www dir.
                        # Do not write directly to www dir to prevent blocking www file.
                        shutil.copyfile(localJsonFileName, wwwJsonFileName)
                        #write csv file too
                        csvFile = open(localCsvFileName, "a")
                        try:
                            lineToWrite = (
                                time.strftime("%b %d %Y %H:%M:%S;") +
                                json.dumps(newRow['BeerTemp']) + ';' +
                                json.dumps(newRow['BeerSet']) + ';' +
                                json.dumps(newRow['BeerAnn']) + ';' +
                                json.dumps(newRow['FridgeTemp']) + ';' +
                                json.dumps(newRow['FridgeSet']) + ';' +
                                json.dumps(newRow['FridgeAnn']) + ';' +
                                json.dumps(newRow['State']) + ';' +