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

Function printerSdCommand

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

Source from the content-addressed store, hash-verified

343@api.route("/printer/sd", methods=["POST"])
344@restricted_access
345def printerSdCommand():
346 if not settings().getBoolean(["feature", "sdSupport"]):
347 return make_response("SD support is disabled", 404)
348
349 pm = printerManager()
350
351 if not pm.isOperational() or pm.isPrinting() or pm.isPaused():
352 return make_response("Printer is not operational or currently busy", 409)
353
354 valid_commands = {
355 "init": [],
356 "refresh": [],
357 "release": []
358 }
359 command, data, response = util.getJsonCommandFromRequest(request, valid_commands)
360 if response is not None:
361 return response
362
363 if command == "init":
364 pm.initSdCard()
365 elif command == "refresh":
366 pm.refreshSdFiles()
367 elif command == "release":
368 pm.releaseSdCard()
369
370 return NO_CONTENT
371
372
373@api.route("/printer/sd", methods=["GET"])

Callers

nothing calls this directly

Calls 9

settingsFunction · 0.90
printerManagerFunction · 0.90
getBooleanMethod · 0.80
isOperationalMethod · 0.45
isPrintingMethod · 0.45
isPausedMethod · 0.45
initSdCardMethod · 0.45
refreshSdFilesMethod · 0.45
releaseSdCardMethod · 0.45

Tested by

no test coverage detected