From 76d0b5f1980356e0ea4f616be244b18b94ee1c22 Mon Sep 17 00:00:00 2001 From: ChrisTerBeke Date: Thu, 18 Apr 2019 14:26:38 +0200 Subject: [PATCH] Ensure printers length is larger than 0 before accessing index --- plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py index 58005a7cc8..4f89513e1e 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py @@ -244,9 +244,10 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice): def _updatePrinters(self, printers: List[CloudClusterPrinterStatus]) -> None: previous = {p.key: p for p in self._printers} # type: Dict[str, PrinterOutputModel] received = {p.uuid: p for p in printers} # type: Dict[str, CloudClusterPrinterStatus] - - # We need the machine type of the host (1st list entry) to allow discovery to work. - self._host_machine_type = printers[0].machine_variant + + if len(printers) > 0: + # We need the machine type of the host (1st list entry) to allow discovery to work. + self._host_machine_type = printers[0].machine_variant removed_printers, added_printers, updated_printers = findChanges(previous, received)