From b734830fcf4ca45a517801d8b298fbc55680d063 Mon Sep 17 00:00:00 2001 From: Nino van Hooff Date: Tue, 9 Jun 2020 17:02:21 +0200 Subject: [PATCH 1/3] Sort new_devices on online status first, name second Since the first device might be activated in case there is no active printer yet, it would be nice to prioritize online devices CURA-7493 --- .../src/Cloud/CloudOutputDeviceManager.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py index 30c26a2c24..ae0e47ad64 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py @@ -163,7 +163,11 @@ class CloudOutputDeviceManager: self._connectToActiveMachine() return - new_devices.sort(key = lambda x: x.name.lower()) + # Sort new_devices on online status first, alphabetical (case-sensitive) second. + # Since the first device might be activated in case there is no active printer yet, + # it would be nice to prioritize online devices + online_cluster_names = {c.friendly_name for c in clusters if c.is_online} + new_devices.sort(key = lambda x: "a{}".format(x.name) if x.name in online_cluster_names else "b{}".format(x.name)) image_path = os.path.join( CuraApplication.getInstance().getPluginRegistry().getPluginPath("UM3NetworkPrinting") or "", From 29442e29e4f91e2d08844cf60fb54d8eb7425c44 Mon Sep 17 00:00:00 2001 From: Remco Burema Date: Tue, 9 Jun 2020 17:28:02 +0200 Subject: [PATCH 2/3] Make printer name sorting case insensitive again. part of CURA-7493 --- .../src/Cloud/CloudOutputDeviceManager.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py index ae0e47ad64..d6868d108b 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py @@ -163,11 +163,11 @@ class CloudOutputDeviceManager: self._connectToActiveMachine() return - # Sort new_devices on online status first, alphabetical (case-sensitive) second. + # Sort new_devices on online status first, alphabetical second. # Since the first device might be activated in case there is no active printer yet, # it would be nice to prioritize online devices - online_cluster_names = {c.friendly_name for c in clusters if c.is_online} - new_devices.sort(key = lambda x: "a{}".format(x.name) if x.name in online_cluster_names else "b{}".format(x.name)) + online_cluster_names = {c.friendly_name.lower() for c in clusters if c.is_online} + new_devices.sort(key = lambda x: ("a{}" if x.name.lower() in online_cluster_names else "b{}").format(x.name.lower())) image_path = os.path.join( CuraApplication.getInstance().getPluginRegistry().getPluginPath("UM3NetworkPrinting") or "", From a38fac9e6752d36c2d766c165bbf11bab0fd3366 Mon Sep 17 00:00:00 2001 From: Remco Burema Date: Tue, 9 Jun 2020 17:34:23 +0200 Subject: [PATCH 3/3] Fix typing. --- .../UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py index d6868d108b..89419c4dd4 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py @@ -166,7 +166,7 @@ class CloudOutputDeviceManager: # Sort new_devices on online status first, alphabetical second. # Since the first device might be activated in case there is no active printer yet, # it would be nice to prioritize online devices - online_cluster_names = {c.friendly_name.lower() for c in clusters if c.is_online} + online_cluster_names = {c.friendly_name.lower() for c in clusters if c.is_online and not c.friendly_name is None} new_devices.sort(key = lambda x: ("a{}" if x.name.lower() in online_cluster_names else "b{}").format(x.name.lower())) image_path = os.path.join(