()
| 21 | |
| 22 | @api.route("/printer", methods=["GET"]) |
| 23 | def printerState(): |
| 24 | pm = printerManager() |
| 25 | |
| 26 | if not pm.isOperational(): |
| 27 | return make_response("Printer is not operational", 409) |
| 28 | |
| 29 | # process excludes |
| 30 | excludes = [] |
| 31 | if "exclude" in request.values: |
| 32 | excludeStr = request.values["exclude"] |
| 33 | if len(excludeStr.strip()) > 0: |
| 34 | excludes = filter(lambda x: x in ["temperature", "sd", "state"], map(lambda x: x.strip(), excludeStr.split(","))) |
| 35 | |
| 36 | result = {} |
| 37 | |
| 38 | # add temperature information |
| 39 | if not "temperature" in excludes: |
| 40 | result.update({"temperature": _getTemperatureData(lambda x: x)}) |
| 41 | |
| 42 | # add sd information |
| 43 | if not "sd" in excludes and settings().getBoolean(["feature", "sdSupport"]): |
| 44 | result.update({"sd": {"ready": pm.isSdReady()}}) |
| 45 | |
| 46 | # add state information |
| 47 | if not "state" in excludes: |
| 48 | state = pm.getCurrentData()["state"] |
| 49 | result.update({"state": state}) |
| 50 | |
| 51 | return jsonify(result) |
| 52 | |
| 53 | |
| 54 | #~~ Tool |
nothing calls this directly
no test coverage detected