Exemplo n.º 1
0
def pressure_get_all():
    logging.debug("Received request /pressures")
    startTime = time.monotonic()
    try:
        dataArray = []
        pressArray = PressureModel.get_all()
        for tempModel in pressArray:
            dataArray.append(tempModel.to_json())
        elapsedTime = time.monotonic() - startTime
        logging.debug("pressure get all request time: " +
                      str(round(elapsedTime, 5)) + " seconds")
        return res(200, data=dataArray, timeUTC=datetime.utcnow())
    except mariadb.Error as e:
        abort(500, str(e))
Exemplo n.º 2
0
    def get_all():
        # init
        foundPressure = []
        foundHumidities = []
        foundCo2 = []
        foundTemperatures = []

        # Execution (4 connection, could be more effecient but query time is hardly an issue)
        foundPressure = PressureModel.get_all()
        foundHumidities = HumidityModel.get_all()
        foundCo2 = CO2Model.get_all()
        foundTemperatures = TemperatureModel.get_all()

        # Build object
        returnObj = SensorModel(foundPressure, foundHumidities, foundCo2,
                                foundTemperatures)

        # Clean and return
        return returnObj