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.
This commit is contained in:
Ghostkeeper 2017-02-07 13:35:09 +01:00
parent 559b40867e
commit 3618ae0d4f
No known key found for this signature in database
GPG key ID: C5F96EE2BC0F7E75

View file

@ -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())