From fa2257aaa35e9bdf7f6b1c2da6f01b5cf2489098 Mon Sep 17 00:00:00 2001 From: Erwan MATHIEU Date: Thu, 7 Mar 2024 16:48:47 +0100 Subject: [PATCH] Add fallback for uuid retrieval from DF CURA-11655 --- .../Http/CloudClusterWithConfigResponse.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/plugins/UM3NetworkPrinting/src/Models/Http/CloudClusterWithConfigResponse.py b/plugins/UM3NetworkPrinting/src/Models/Http/CloudClusterWithConfigResponse.py index eb6389910c5..4ea73d0ccbd 100644 --- a/plugins/UM3NetworkPrinting/src/Models/Http/CloudClusterWithConfigResponse.py +++ b/plugins/UM3NetworkPrinting/src/Models/Http/CloudClusterWithConfigResponse.py @@ -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)