mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-15 04:05:54 +08:00
Add input checking for incorrect responses from printers
We should not crash when getting invalid data. Just put a warning in the log there and ignore the message for the rest.
This commit is contained in:
parent
b7493ae1a8
commit
df88772071
@ -117,7 +117,14 @@ class NetworkPrinterOutputDevicePlugin(OutputDevicePlugin):
|
|||||||
if reply.operation() == QNetworkAccessManager.GetOperation:
|
if reply.operation() == QNetworkAccessManager.GetOperation:
|
||||||
if "system" in reply_url: # Name returned from printer.
|
if "system" in reply_url: # Name returned from printer.
|
||||||
if status_code == 200:
|
if status_code == 200:
|
||||||
|
try:
|
||||||
system_info = json.loads(bytes(reply.readAll()).decode("utf-8"))
|
system_info = json.loads(bytes(reply.readAll()).decode("utf-8"))
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
Logger.log("e", "Printer returned invalid JSON.")
|
||||||
|
return
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
Logger.log("e", "Printer returned incorrect UTF-8.")
|
||||||
|
return
|
||||||
address = reply.url().host()
|
address = reply.url().host()
|
||||||
|
|
||||||
instance_name = "manual:%s" % address
|
instance_name = "manual:%s" % address
|
||||||
|
Loading…
x
Reference in New Issue
Block a user