From 3618ae0d4f9e9435ac7ba093927f9ac7de83b862 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 7 Feb 2017 13:35:09 +0100 Subject: [PATCH] Properly float-format input of preheatBed It rounds to 3 digits. The specification of the feature in the API doesn't mention how detailed the temperature and duration can go, but thousands seems more than enough. This also eliminates pesky problems with the JSON brackets in the format function. Contributes to issue CURA-3161. --- plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py index 59c04dd822..87986afbf3 100644 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py @@ -249,7 +249,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): @pyqtSlot(float, float) def preheatBed(self, temperature, duration=900): url = QUrl("http://" + self._address + self._api_prefix + "printer/bed/pre_heat") - data = """{"temperature": "{temperature}", "timeout": "{timeout}"}""".format(temperature=str(temperature), timeout=str(duration)) + data = """{"temperature": "%0.3f", "timeout": "%0.3f"}""" % (temperature, duration) put_request = QNetworkRequest(url) put_request.setHeader(QNetworkRequest.ContentTypeHeader, "application/json") self._manager.put(put_request, data.encode())