()
| 40 | |
| 41 | @api.route("/settings/printer", methods=["GET", "POST"]) |
| 42 | def handlePrinterSettings(): |
| 43 | s = settings() |
| 44 | pm = printerManager() |
| 45 | ppm = printerProfileManager() |
| 46 | connectionOptions = pm.getConnectionOptions() |
| 47 | |
| 48 | if request.method == "POST": |
| 49 | if "application/json" in request.headers["Content-Type"]: |
| 50 | data = request.json |
| 51 | |
| 52 | if "serial" in data.keys(): |
| 53 | if "port" in data["serial"].keys(): s.set(["serial", "port"], data["serial"]["port"]) |
| 54 | if "baudrate" in data["serial"].keys(): s.setInt(["serial", "baudrate"], data["serial"]["baudrate"]) |
| 55 | |
| 56 | s.save() |
| 57 | |
| 58 | driverName = ppm.data['driver'] |
| 59 | driverInfo = ppm.driverChoices().get(driverName) |
| 60 | if driverInfo: |
| 61 | driverName = driverInfo['name'] |
| 62 | |
| 63 | return jsonify({ |
| 64 | "driver": ppm.data['driver'], |
| 65 | "driverName": driverName, |
| 66 | "serial": { |
| 67 | "port": connectionOptions["portPreference"], |
| 68 | "baudrate": connectionOptions["baudratePreference"], |
| 69 | "portOptions": connectionOptions["ports"].items(), |
| 70 | "baudrateOptions": connectionOptions["baudrates"] |
| 71 | } |
| 72 | }) |
| 73 | |
| 74 | @api.route("/settings/network/name", methods=["GET", "POST"]) |
| 75 | @restricted_access |
nothing calls this directly
no test coverage detected