Add fallback for uuid retrieval from DF

CURA-11655
This commit is contained in:
Erwan MATHIEU 2024-03-07 16:48:47 +01:00
parent 5f5758c49d
commit fa2257aaa3

View file

@ -2,6 +2,8 @@
# Cura is released under the terms of the LGPLv3 or higher.
from typing import Optional, List
import uuid
from .CloudClusterResponse import CloudClusterResponse
from .ClusterPrinterStatus import ClusterPrinterStatus
@ -11,4 +13,20 @@ class CloudClusterWithConfigResponse(CloudClusterResponse):
def __init__(self, **kwargs) -> None:
self.configuration = self.parseModel(ClusterPrinterStatus, kwargs.get("host_printer"))
# Some printers will return a null UUID in the host_printer.uuid field. For those we can fall back using
# the host_guid field of the cluster data
valid_uuid = False
try:
parsed_uuid = uuid.UUID(self.configuration.uuid)
valid_uuid = parsed_uuid.int != 0
except:
pass
if not valid_uuid:
try:
self.configuration.uuid = kwargs.get("host_guid")
except:
pass
super().__init__(**kwargs)