Esempio n. 1
0
def _get_temperature_data(preprocessor):
    if not printer.is_operational():
        abort(409, description="Printer is not operational")

    tempData = printer.get_current_temperatures()

    if "history" in request.values and request.values["history"] in valid_boolean_trues:
        history = printer.get_temperature_history()

        limit = 300
        if "limit" in request.values and str(request.values["limit"]).isnumeric():
            limit = int(request.values["limit"])

        limit = min(limit, len(history))

        tempData.update(
            {"history": list(map(lambda x: preprocessor(x), history[-limit:]))}
        )

    return preprocessor(tempData)
Esempio n. 2
0
def _getTemperatureData(filter):
	if not printer.is_operational():
		return make_response("Printer is not operational", 409)

	tempData = printer.get_current_temperatures()

	if "history" in request.values.keys() and request.values["history"] in valid_boolean_trues:
		tempHistory = printer.get_temperature_history()

		limit = 300
		if "limit" in request.values.keys() and unicode(request.values["limit"]).isnumeric():
			limit = int(request.values["limit"])

		history = list(tempHistory)
		limit = min(limit, len(history))

		tempData.update({
			"history": map(lambda x: filter(x), history[-limit:])
		})

	return filter(tempData)
Esempio n. 3
0
def _get_temperature_data(preprocessor):
    if not printer.is_operational():
        return make_response("Printer is not operational", 409)

    tempData = printer.get_current_temperatures()

    if "history" in list(request.values.keys(
    )) and request.values["history"] in valid_boolean_trues:
        tempHistory = printer.get_temperature_history()

        limit = 300
        if "limit" in list(request.values.keys()) and str(
                request.values["limit"]).isnumeric():
            limit = int(request.values["limit"])

        history = list(tempHistory)
        limit = min(limit, len(history))

        tempData.update(
            {"history": [preprocessor(x) for x in history[-limit:]]})

    return preprocessor(tempData)