MCPcopy Create free account
hub / github.com/AstroPrint/AstroBox / printerState

Function printerState

src/astroprint/api/printer.py:23–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21
22@api.route("/printer", methods=["GET"])
23def 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

Callers

nothing calls this directly

Calls 8

printerManagerFunction · 0.90
settingsFunction · 0.90
_getTemperatureDataFunction · 0.85
updateMethod · 0.80
getBooleanMethod · 0.80
isOperationalMethod · 0.45
isSdReadyMethod · 0.45
getCurrentDataMethod · 0.45

Tested by

no test coverage detected