From 35a9a0a0583f179e0895525d9ba2a442183ee7ca Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Mon, 4 Mar 2019 15:52:00 +0100 Subject: [PATCH 01/18] Check for IP addresses used as network keys Contributes to CL-1266 --- .../src/Cloud/CloudOutputDevice.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py index 7b5add276a..b89fc9d61d 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py @@ -140,9 +140,17 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice): ## Checks whether the given network key is found in the cloud's host name def matchesNetworkKey(self, network_key: str) -> bool: - # A network key looks like "ultimakersystem-aabbccdd0011._ultimaker._tcp.local." + # Typically, a network key looks like "ultimakersystem-aabbccdd0011._ultimaker._tcp.local." # the host name should then be "ultimakersystem-aabbccdd0011" - return network_key.startswith(self.clusterData.host_name) + if network_key.startswith(self.clusterData.host_name): + return True + + # However, for manually added printers, the local IP address is used in lieu of a proper + # network key, so check for that as well + if network_key == self.clusterData.host_internal_ip: + return True + + return False ## Set all the interface elements and texts for this output device. def _setInterfaceElements(self) -> None: From 63bf95cc9e29cb3d306bcdb4d8837e10aa8bfcd3 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Mon, 4 Mar 2019 16:26:20 +0100 Subject: [PATCH 02/18] More robust check for network key Contributes to CL-1266 --- plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py index b89fc9d61d..f78f5e91c0 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py @@ -147,7 +147,7 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice): # However, for manually added printers, the local IP address is used in lieu of a proper # network key, so check for that as well - if network_key == self.clusterData.host_internal_ip: + if network_key.find(self.clusterData.host_internal_ip): return True return False From 04a2caf7815d72888cf41993d0e6f890504925dd Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Mon, 4 Mar 2019 16:29:23 +0100 Subject: [PATCH 03/18] Add internal IP to CloudClusterResponse Contributes to CL-1266 --- .../src/Cloud/Models/CloudClusterResponse.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterResponse.py b/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterResponse.py index 9c0853e7c9..f071c61f67 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterResponse.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterResponse.py @@ -16,13 +16,14 @@ class CloudClusterResponse(BaseCloudModel): # \param status: The status of the cluster authentication (active or inactive). # \param host_version: The firmware version of the cluster host. This is where the Stardust client is running on. def __init__(self, cluster_id: str, host_guid: str, host_name: str, is_online: bool, status: str, - host_version: Optional[str] = None, **kwargs) -> None: + host_internal_ip: str, host_version: Optional[str] = None, **kwargs) -> None: self.cluster_id = cluster_id self.host_guid = host_guid self.host_name = host_name self.status = status self.is_online = is_online self.host_version = host_version + self.host_internal_ip = host_internal_ip super().__init__(**kwargs) # Validates the model, raising an exception if the model is invalid. From d758189aafe809397a6caa9616a09e41bb5ef251 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Tue, 5 Mar 2019 09:28:18 +0100 Subject: [PATCH 04/18] Adapt tests to manual IP connection Contributes to CL-1266 --- .../tests/Cloud/TestCloudOutputDevice.py | 12 ++++++++++-- .../tests/Cloud/TestCloudOutputDeviceManager.py | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDevice.py b/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDevice.py index c4d891302e..6ba6436694 100644 --- a/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDevice.py +++ b/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDevice.py @@ -22,6 +22,7 @@ class TestCloudOutputDevice(TestCase): HOST_NAME = "ultimakersystem-ccbdd30044ec" HOST_GUID = "e90ae0ac-1257-4403-91ee-a44c9b7e8050" HOST_VERSION = "5.2.0" + HOST_INTERNAL_IP = "10.183.0.139" STATUS_URL = "{}/connect/v1/clusters/{}/status".format(CuraCloudAPIRoot, CLUSTER_ID) PRINT_URL = "{}/connect/v1/clusters/{}/print/{}".format(CuraCloudAPIRoot, CLUSTER_ID, JOB_ID) @@ -36,8 +37,15 @@ class TestCloudOutputDevice(TestCase): for patched_method in self.patches: patched_method.start() - self.cluster = CloudClusterResponse(self.CLUSTER_ID, self.HOST_GUID, self.HOST_NAME, is_online=True, - status="active", host_version=self.HOST_VERSION) + self.cluster = CloudClusterResponse( + self.CLUSTER_ID, + self.HOST_GUID, + self.HOST_NAME, + is_online=True, + status="active", + host_internal_ip=self.HOST_INTERNAL_IP, + host_version=self.HOST_VERSION + ) self.network = NetworkManagerMock() self.account = MagicMock(isLoggedIn=True, accessToken="TestAccessToken") diff --git a/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDeviceManager.py b/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDeviceManager.py index e24ca1694e..b34943c613 100644 --- a/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDeviceManager.py +++ b/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDeviceManager.py @@ -113,6 +113,20 @@ class TestCloudOutputDeviceManager(TestCase): active_machine_mock.setMetaDataEntry.assert_called_with("um_cloud_cluster_id", cluster2["cluster_id"]) + def test_device_connects_by_local_ip_address(self): + active_machine_mock = self.app.getGlobalContainerStack.return_value + + cluster1, cluster2 = self.clusters_response["data"] + network_key = cluster2["host_internal_ip"] + active_machine_mock.getMetaDataEntry.side_effect = {"um_network_key": network_key}.get + + self._loadData() + + self.assertIsNone(self.device_manager.getOutputDevice(cluster1["cluster_id"])) + self.assertTrue(self.device_manager.getOutputDevice(cluster2["cluster_id"]).isConnected()) + + active_machine_mock.setMetaDataEntry.assert_called_with("um_cloud_cluster_id", cluster2["cluster_id"]) + @patch.object(CloudOutputDeviceManager, "Message") def test_api_error(self, message_mock): self.clusters_response = { From f483eb431f9192026be348a672cb38c5337db328 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Tue, 5 Mar 2019 09:30:51 +0100 Subject: [PATCH 05/18] Make IP address optional Contribues to CL-1266 --- .../UM3NetworkPrinting/src/Cloud/Models/CloudClusterResponse.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterResponse.py b/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterResponse.py index f071c61f67..6e49e9e2a9 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterResponse.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterResponse.py @@ -16,7 +16,7 @@ class CloudClusterResponse(BaseCloudModel): # \param status: The status of the cluster authentication (active or inactive). # \param host_version: The firmware version of the cluster host. This is where the Stardust client is running on. def __init__(self, cluster_id: str, host_guid: str, host_name: str, is_online: bool, status: str, - host_internal_ip: str, host_version: Optional[str] = None, **kwargs) -> None: + host_internal_ip: Optional[str], host_version: Optional[str] = None, **kwargs) -> None: self.cluster_id = cluster_id self.host_guid = host_guid self.host_name = host_name From c9d99e01498c6be342c9a7d2c50902e543b3e1fd Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Wed, 6 Mar 2019 13:11:43 +0100 Subject: [PATCH 06/18] Revert "Adapt tests to manual IP connection" This reverts commit d758189aafe809397a6caa9616a09e41bb5ef251. --- .../tests/Cloud/TestCloudOutputDevice.py | 12 ++---------- .../tests/Cloud/TestCloudOutputDeviceManager.py | 14 -------------- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDevice.py b/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDevice.py index 6ba6436694..c4d891302e 100644 --- a/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDevice.py +++ b/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDevice.py @@ -22,7 +22,6 @@ class TestCloudOutputDevice(TestCase): HOST_NAME = "ultimakersystem-ccbdd30044ec" HOST_GUID = "e90ae0ac-1257-4403-91ee-a44c9b7e8050" HOST_VERSION = "5.2.0" - HOST_INTERNAL_IP = "10.183.0.139" STATUS_URL = "{}/connect/v1/clusters/{}/status".format(CuraCloudAPIRoot, CLUSTER_ID) PRINT_URL = "{}/connect/v1/clusters/{}/print/{}".format(CuraCloudAPIRoot, CLUSTER_ID, JOB_ID) @@ -37,15 +36,8 @@ class TestCloudOutputDevice(TestCase): for patched_method in self.patches: patched_method.start() - self.cluster = CloudClusterResponse( - self.CLUSTER_ID, - self.HOST_GUID, - self.HOST_NAME, - is_online=True, - status="active", - host_internal_ip=self.HOST_INTERNAL_IP, - host_version=self.HOST_VERSION - ) + self.cluster = CloudClusterResponse(self.CLUSTER_ID, self.HOST_GUID, self.HOST_NAME, is_online=True, + status="active", host_version=self.HOST_VERSION) self.network = NetworkManagerMock() self.account = MagicMock(isLoggedIn=True, accessToken="TestAccessToken") diff --git a/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDeviceManager.py b/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDeviceManager.py index b34943c613..e24ca1694e 100644 --- a/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDeviceManager.py +++ b/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDeviceManager.py @@ -113,20 +113,6 @@ class TestCloudOutputDeviceManager(TestCase): active_machine_mock.setMetaDataEntry.assert_called_with("um_cloud_cluster_id", cluster2["cluster_id"]) - def test_device_connects_by_local_ip_address(self): - active_machine_mock = self.app.getGlobalContainerStack.return_value - - cluster1, cluster2 = self.clusters_response["data"] - network_key = cluster2["host_internal_ip"] - active_machine_mock.getMetaDataEntry.side_effect = {"um_network_key": network_key}.get - - self._loadData() - - self.assertIsNone(self.device_manager.getOutputDevice(cluster1["cluster_id"])) - self.assertTrue(self.device_manager.getOutputDevice(cluster2["cluster_id"]).isConnected()) - - active_machine_mock.setMetaDataEntry.assert_called_with("um_cloud_cluster_id", cluster2["cluster_id"]) - @patch.object(CloudOutputDeviceManager, "Message") def test_api_error(self, message_mock): self.clusters_response = { From 637e18a841067e8681e283ed6dd281dc435ff5ae Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Wed, 27 Mar 2019 15:40:06 +0100 Subject: [PATCH 07/18] Add default value for internal IP if not supplied Contributes to CL-1266 --- .../UM3NetworkPrinting/src/Cloud/Models/CloudClusterResponse.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterResponse.py b/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterResponse.py index 6e49e9e2a9..207d0bffa9 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterResponse.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterResponse.py @@ -16,7 +16,7 @@ class CloudClusterResponse(BaseCloudModel): # \param status: The status of the cluster authentication (active or inactive). # \param host_version: The firmware version of the cluster host. This is where the Stardust client is running on. def __init__(self, cluster_id: str, host_guid: str, host_name: str, is_online: bool, status: str, - host_internal_ip: Optional[str], host_version: Optional[str] = None, **kwargs) -> None: + host_internal_ip: Optional[str] = "", host_version: Optional[str] = None, **kwargs) -> None: self.cluster_id = cluster_id self.host_guid = host_guid self.host_name = host_name From 4581c1f1384dc4842faeb99a4a0355c375d4f55f Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Thu, 28 Mar 2019 16:20:01 +0100 Subject: [PATCH 08/18] Fix UM3NetworkPrinting test Contributes to CL-1266 --- .../UM3NetworkPrinting/tests/Cloud/Fixtures/getClusters.json | 2 ++ .../tests/Cloud/TestCloudOutputDeviceManager.py | 2 +- plugins/UM3NetworkPrinting/tests/TestSendMaterialJob.py | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/UM3NetworkPrinting/tests/Cloud/Fixtures/getClusters.json b/plugins/UM3NetworkPrinting/tests/Cloud/Fixtures/getClusters.json index 5200e3b971..a749721518 100644 --- a/plugins/UM3NetworkPrinting/tests/Cloud/Fixtures/getClusters.json +++ b/plugins/UM3NetworkPrinting/tests/Cloud/Fixtures/getClusters.json @@ -4,6 +4,7 @@ "host_guid": "e90ae0ac-1257-4403-91ee-a44c9b7e8050", "host_name": "ultimakersystem-ccbdd30044ec", "host_version": "5.0.0.20170101", + "host_internal_ip": "", "is_online": true, "status": "active" }, { @@ -11,6 +12,7 @@ "host_guid": "e0ace90a-91ee-1257-4403-e8050a44c9b7", "host_name": "ultimakersystem-30044ecccbdd", "host_version": "5.1.2.20180807", + "host_internal_ip": "", "is_online": true, "status": "active" }] diff --git a/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDeviceManager.py b/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDeviceManager.py index e24ca1694e..ff7c6b2b67 100644 --- a/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDeviceManager.py +++ b/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDeviceManager.py @@ -97,7 +97,7 @@ class TestCloudOutputDeviceManager(TestCase): self.assertTrue(self.device_manager.getOutputDevice(cluster1["cluster_id"]).isConnected()) self.assertIsNone(self.device_manager.getOutputDevice(cluster2["cluster_id"])) - self.assertEquals([], active_machine_mock.setMetaDataEntry.mock_calls) + self.assertEqual([], active_machine_mock.setMetaDataEntry.mock_calls) def test_device_connects_by_network_key(self): active_machine_mock = self.app.getGlobalContainerStack.return_value diff --git a/plugins/UM3NetworkPrinting/tests/TestSendMaterialJob.py b/plugins/UM3NetworkPrinting/tests/TestSendMaterialJob.py index 952d38dcf4..2cab110861 100644 --- a/plugins/UM3NetworkPrinting/tests/TestSendMaterialJob.py +++ b/plugins/UM3NetworkPrinting/tests/TestSendMaterialJob.py @@ -208,7 +208,7 @@ class TestSendMaterialJob(TestCase): self.assertEqual(1, device_mock.createFormPart.call_count) self.assertEqual(1, device_mock.postFormWithParts.call_count) - self.assertEquals( + self.assertEqual( [call.createFormPart("name=\"file\"; filename=\"generic_pla_white.xml.fdm_material\"", ""), call.postFormWithParts(target = "materials/", parts = ["_xXx_"], on_finished = job.sendingFinished)], device_mock.method_calls) @@ -238,7 +238,7 @@ class TestSendMaterialJob(TestCase): self.assertEqual(1, device_mock.createFormPart.call_count) self.assertEqual(1, device_mock.postFormWithParts.call_count) - self.assertEquals( + self.assertEqual( [call.createFormPart("name=\"file\"; filename=\"generic_pla_white.xml.fdm_material\"", ""), call.postFormWithParts(target = "materials/", parts = ["_xXx_"], on_finished = job.sendingFinished)], device_mock.method_calls) From 58f1c055647c35f0c4d67389ad402f8f320def9d Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Fri, 29 Mar 2019 12:27:58 +0100 Subject: [PATCH 09/18] Actually fix tests Contributes to CL-1266 --- .../src/Cloud/Models/CloudClusterResponse.py | 2 +- .../UM3NetworkPrinting/tests/Cloud/Fixtures/getClusters.json | 2 -- .../tests/Cloud/TestCloudOutputDeviceManager.py | 5 ++++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterResponse.py b/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterResponse.py index 207d0bffa9..48a4d5f031 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterResponse.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterResponse.py @@ -16,7 +16,7 @@ class CloudClusterResponse(BaseCloudModel): # \param status: The status of the cluster authentication (active or inactive). # \param host_version: The firmware version of the cluster host. This is where the Stardust client is running on. def __init__(self, cluster_id: str, host_guid: str, host_name: str, is_online: bool, status: str, - host_internal_ip: Optional[str] = "", host_version: Optional[str] = None, **kwargs) -> None: + host_internal_ip: Optional[str] = None, host_version: Optional[str] = None, **kwargs) -> None: self.cluster_id = cluster_id self.host_guid = host_guid self.host_name = host_name diff --git a/plugins/UM3NetworkPrinting/tests/Cloud/Fixtures/getClusters.json b/plugins/UM3NetworkPrinting/tests/Cloud/Fixtures/getClusters.json index a749721518..5200e3b971 100644 --- a/plugins/UM3NetworkPrinting/tests/Cloud/Fixtures/getClusters.json +++ b/plugins/UM3NetworkPrinting/tests/Cloud/Fixtures/getClusters.json @@ -4,7 +4,6 @@ "host_guid": "e90ae0ac-1257-4403-91ee-a44c9b7e8050", "host_name": "ultimakersystem-ccbdd30044ec", "host_version": "5.0.0.20170101", - "host_internal_ip": "", "is_online": true, "status": "active" }, { @@ -12,7 +11,6 @@ "host_guid": "e0ace90a-91ee-1257-4403-e8050a44c9b7", "host_name": "ultimakersystem-30044ecccbdd", "host_version": "5.1.2.20180807", - "host_internal_ip": "", "is_online": true, "status": "active" }] diff --git a/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDeviceManager.py b/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDeviceManager.py index ff7c6b2b67..869b39440c 100644 --- a/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDeviceManager.py +++ b/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDeviceManager.py @@ -7,6 +7,7 @@ from UM.OutputDevice.OutputDeviceManager import OutputDeviceManager from cura.UltimakerCloudAuthentication import CuraCloudAPIRoot from ...src.Cloud import CloudApiClient from ...src.Cloud import CloudOutputDeviceManager +from ...src.Cloud.Models.CloudClusterResponse import CloudClusterResponse from .Fixtures import parseFixture, readFixture from .NetworkManagerMock import NetworkManagerMock, FakeSignal @@ -55,7 +56,9 @@ class TestCloudOutputDeviceManager(TestCase): devices = self.device_manager.getOutputDevices() # TODO: Check active device - response_clusters = self.clusters_response.get("data", []) + response_clusters = [] + for cluster in self.clusters_response.get("data", []): + response_clusters.append(CloudClusterResponse(**cluster).toDict()) manager_clusters = sorted([device.clusterData.toDict() for device in self.manager._remote_clusters.values()], key=lambda cluster: cluster['cluster_id'], reverse=True) self.assertEqual(response_clusters, manager_clusters) From 19c6fceb0cfdecb38747c3f842e6c03d08681011 Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Mon, 1 Apr 2019 14:30:20 +0200 Subject: [PATCH 10/18] Delay using `getPluginPath()` until after start up time CL-1266 --- plugins/UM3NetworkPrinting/src/LegacyUM3OutputDevice.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/UM3NetworkPrinting/src/LegacyUM3OutputDevice.py b/plugins/UM3NetworkPrinting/src/LegacyUM3OutputDevice.py index 2c7c33d382..7d3a76e749 100644 --- a/plugins/UM3NetworkPrinting/src/LegacyUM3OutputDevice.py +++ b/plugins/UM3NetworkPrinting/src/LegacyUM3OutputDevice.py @@ -77,13 +77,15 @@ class LegacyUM3OutputDevice(NetworkedPrinterOutputDevice): self.setIconName("print") - if PluginRegistry.getInstance() is not None: + self._output_controller = LegacyUM3PrinterOutputController(self) + + def _createMonitorViewFromQML(self) -> None: + if self._monitor_view_qml_path is None and PluginRegistry.getInstance() is not None: self._monitor_view_qml_path = os.path.join( PluginRegistry.getInstance().getPluginPath("UM3NetworkPrinting"), "resources", "qml", "MonitorStage.qml" ) - - self._output_controller = LegacyUM3PrinterOutputController(self) + super()._createMonitorViewFromQML() def _onAuthenticationStateChanged(self): # We only accept commands if we are authenticated. From 5105b67a8c5f3ca71a9234cbbda0a43443bdcbd3 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 1 Apr 2019 15:18:49 +0200 Subject: [PATCH 11/18] Remove unused entries from the theme --- plugins/Toolbox/resources/qml/ToolboxDownloadsShowcase.qml | 2 +- plugins/Toolbox/resources/qml/ToolboxTabButton.qml | 2 +- resources/themes/cura-light/theme.json | 4 ---- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/plugins/Toolbox/resources/qml/ToolboxDownloadsShowcase.qml b/plugins/Toolbox/resources/qml/ToolboxDownloadsShowcase.qml index 795622cf82..72dd6f91a2 100644 --- a/plugins/Toolbox/resources/qml/ToolboxDownloadsShowcase.qml +++ b/plugins/Toolbox/resources/qml/ToolboxDownloadsShowcase.qml @@ -14,7 +14,7 @@ Rectangle Column { height: childrenRect.height + 2 * padding - spacing: UM.Theme.getSize("toolbox_showcase_spacing").width + spacing: UM.Theme.getSize("default_margin").width width: parent.width padding: UM.Theme.getSize("wide_margin").height Label diff --git a/plugins/Toolbox/resources/qml/ToolboxTabButton.qml b/plugins/Toolbox/resources/qml/ToolboxTabButton.qml index cde87c5bc4..7a7d2be48a 100644 --- a/plugins/Toolbox/resources/qml/ToolboxTabButton.qml +++ b/plugins/Toolbox/resources/qml/ToolboxTabButton.qml @@ -61,7 +61,7 @@ Button { target: label font: UM.Theme.getFont("medium_bold") - color: UM.Theme.getColor("toolbox_header_button_text_active") + color: UM.Theme.getColor("action_button_text") } } ] diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index 8097ee498d..91ce85a74d 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -384,7 +384,6 @@ "printer_config_matched": [50, 130, 255, 255], "printer_config_mismatch": [127, 127, 127, 255], - "toolbox_header_button_text_active": [0, 0, 0, 255], "toolbox_header_button_text_inactive": [0, 0, 0, 255], "favorites_header_bar": [245, 245, 245, 255], @@ -580,10 +579,8 @@ "toolbox_thumbnail_large": [12.0, 10.0], "toolbox_footer": [1.0, 4.5], "toolbox_footer_button": [8.0, 2.5], - "toolbox_showcase_spacing": [1.0, 1.0], "toolbox_header_tab": [8.0, 4.0], "toolbox_detail_header": [1.0, 14.0], - "toolbox_detail_tile": [1.0, 8.0], "toolbox_back_column": [6.0, 1.0], "toolbox_back_button": [6.0, 2.0], "toolbox_installed_tile": [1.0, 8.0], @@ -591,7 +588,6 @@ "toolbox_heading_label": [1.0, 3.8], "toolbox_header": [1.0, 4.0], "toolbox_header_highlight": [0.25, 0.25], - "toolbox_progress_bar": [8.0, 0.5], "toolbox_chart_row": [1.0, 2.0], "toolbox_action_button": [8.0, 2.5], "toolbox_loader": [2.0, 2.0], From 8700cbe4e85ee130430baeba62c254cf1d07353b Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Mon, 1 Apr 2019 15:22:38 +0200 Subject: [PATCH 12/18] Mypy fix CL-1266 --- plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py index 07dc962bf8..0c044bbb56 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py @@ -152,7 +152,7 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice): # However, for manually added printers, the local IP address is used in lieu of a proper # network key, so check for that as well - if network_key.find(self.clusterData.host_internal_ip): + if self.clusterData.host_internal_ip is not None and network_key.find(self.clusterData.host_internal_ip): return True return False From dc66bdacc695133cf3ceb81765e055272b7cbdf9 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 1 Apr 2019 16:27:46 +0200 Subject: [PATCH 13/18] Simplify the main_window_header_tab style --- resources/themes/cura-light/styles.qml | 34 ++++++++++++-------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/resources/themes/cura-light/styles.qml b/resources/themes/cura-light/styles.qml index 121f604362..8f10695048 100755 --- a/resources/themes/cura-light/styles.qml +++ b/resources/themes/cura-light/styles.qml @@ -103,33 +103,29 @@ QtObject // This property will be back-propagated when the width of the label is calculated property var buttonWidth: 0 - background: Item + background: Rectangle { + id: backgroundRectangle implicitHeight: control.height implicitWidth: buttonWidth - Rectangle - { - id: buttonFace - implicitHeight: parent.height - implicitWidth: parent.width - radius: UM.Theme.getSize("action_button_radius").width + radius: UM.Theme.getSize("action_button_radius").width - color: + color: + { + if (control.checked) { - if (control.checked) + return UM.Theme.getColor("main_window_header_button_background_active") + } + else + { + if (control.hovered) { - return UM.Theme.getColor("main_window_header_button_background_active") - } - else - { - if (control.hovered) - { - return UM.Theme.getColor("main_window_header_button_background_hovered") - } - return UM.Theme.getColor("main_window_header_button_background_inactive") + return UM.Theme.getColor("main_window_header_button_background_hovered") } + return UM.Theme.getColor("main_window_header_button_background_inactive") } } + } label: Item @@ -168,6 +164,8 @@ QtObject buttonWidth = width } } + + } } From 8b28dfb5e20d6b46de23b4ded6634f3aeed6aafd Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 1 Apr 2019 16:30:31 +0200 Subject: [PATCH 14/18] Removed unused style --- resources/themes/cura-light/styles.qml | 67 -------------------------- 1 file changed, 67 deletions(-) diff --git a/resources/themes/cura-light/styles.qml b/resources/themes/cura-light/styles.qml index 8f10695048..2cf3b0ed58 100755 --- a/resources/themes/cura-light/styles.qml +++ b/resources/themes/cura-light/styles.qml @@ -396,73 +396,6 @@ QtObject } } - // Combobox with items with colored rectangles - property Component combobox_color: Component - { - - ComboBoxStyle - { - - background: Rectangle - { - color: !enabled ? UM.Theme.getColor("setting_control_disabled") : control._hovered ? UM.Theme.getColor("setting_control_highlight") : UM.Theme.getColor("setting_control") - border.width: UM.Theme.getSize("default_lining").width - border.color: !enabled ? UM.Theme.getColor("setting_control_disabled_border") : control._hovered ? UM.Theme.getColor("setting_control_border_highlight") : UM.Theme.getColor("setting_control_border") - radius: UM.Theme.getSize("setting_control_radius").width - } - - label: Item - { - Label - { - anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("default_lining").width - anchors.right: swatch.left - anchors.rightMargin: UM.Theme.getSize("default_lining").width - anchors.verticalCenter: parent.verticalCenter - - text: control.currentText - font: UM.Theme.getFont("default") - color: !enabled ? UM.Theme.getColor("setting_control_disabled_text") : UM.Theme.getColor("setting_control_text") - - elide: Text.ElideRight - verticalAlignment: Text.AlignVCenter - } - - UM.RecolorImage - { - id: swatch - height: Math.round(control.height / 2) - width: height - anchors.right: downArrow.left - anchors.verticalCenter: parent.verticalCenter - anchors.rightMargin: UM.Theme.getSize("default_margin").width - - sourceSize.width: width - sourceSize.height: height - source: UM.Theme.getIcon("extruder_button") - color: (control.color_override !== "") ? control.color_override : control.color - } - - UM.RecolorImage - { - id: downArrow - anchors.right: parent.right - anchors.rightMargin: UM.Theme.getSize("default_lining").width * 2 - anchors.verticalCenter: parent.verticalCenter - - source: UM.Theme.getIcon("arrow_bottom") - width: UM.Theme.getSize("standard_arrow").width - height: UM.Theme.getSize("standard_arrow").height - sourceSize.width: width + 5 * screenScaleFactor - sourceSize.height: width + 5 * screenScaleFactor - - color: UM.Theme.getColor("setting_control_button") - } - } - } - } - property Component checkbox: Component { CheckBoxStyle From 8ae0c695bd7944f6e647b9a5d01889eb7fb66a2f Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 2 Apr 2019 11:09:12 +0200 Subject: [PATCH 15/18] Add total cost to the output overview. This fixes #5529 --- resources/qml/ActionPanel/OutputProcessWidget.qml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/resources/qml/ActionPanel/OutputProcessWidget.qml b/resources/qml/ActionPanel/OutputProcessWidget.qml index f4505c620c..7e76768cb4 100644 --- a/resources/qml/ActionPanel/OutputProcessWidget.qml +++ b/resources/qml/ActionPanel/OutputProcessWidget.qml @@ -68,6 +68,7 @@ Column property var printMaterialLengths: PrintInformation.materialLengths property var printMaterialWeights: PrintInformation.materialWeights + property var printMaterialCosts: PrintInformation.materialCosts text: { @@ -77,6 +78,7 @@ Column } var totalLengths = 0 var totalWeights = 0 + var totalCosts = 0.0 if (printMaterialLengths) { for(var index = 0; index < printMaterialLengths.length; index++) @@ -85,9 +87,16 @@ Column { totalLengths += printMaterialLengths[index] totalWeights += Math.round(printMaterialWeights[index]) + var cost = printMaterialCosts[index] == undefined ? 0.0 : printMaterialCosts[index] + totalCosts += cost } } } + if(totalCosts > 0) + { + var costString = "%1 %2".arg(UM.Preferences.getValue("cura/currency")).arg(totalCosts.toFixed(2)) + return totalWeights + "g · " + totalLengths.toFixed(2) + "m · " + costString + } return totalWeights + "g · " + totalLengths.toFixed(2) + "m" } source: UM.Theme.getIcon("spool") From 168c4e17c686885d74108c72112ff6b216b30421 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 2 Apr 2019 11:42:26 +0200 Subject: [PATCH 16/18] Reduce support horizontal expansion to 0 We have a long-standing issue in CuraEngine that support can be thinner than one line width and is then not generated, but if there is later some extra room it still gets supported in lower layers. This results in unnecessary support. That issue in itself is a bit hairy to fix. But it does point out to another weirdness: PLA support has a horizontal offset of 0.2mm. This was introduced when the Support Horizontal Expansion setting was made as the default, but it was never really investigated. I asked Ultimaker's process engineers and we agreed that the setting could be set to 0 except for PVA. Contributes to issue CURA-6438. --- resources/definitions/fdmprinter.def.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/definitions/fdmprinter.def.json b/resources/definitions/fdmprinter.def.json index 45ff92fea8..cb28a439ee 100644 --- a/resources/definitions/fdmprinter.def.json +++ b/resources/definitions/fdmprinter.def.json @@ -4092,7 +4092,7 @@ "description": "Amount of offset applied to all support polygons in each layer. Positive values can smooth out the support areas and result in more sturdy support.", "unit": "mm", "type": "float", - "default_value": 0.2, + "default_value": 0, "limit_to_extruder": "support_infill_extruder_nr", "minimum_value_warning": "-1 * machine_nozzle_size", "maximum_value_warning": "10 * machine_nozzle_size", From efe8f191097c7050d5a7575b1cc5a1f94e6b4e7d Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 2 Apr 2019 11:46:12 +0200 Subject: [PATCH 17/18] Return the value for default extruder if the requested one could not be found This fixes #5535 --- cura/Settings/CuraFormulaFunctions.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cura/Settings/CuraFormulaFunctions.py b/cura/Settings/CuraFormulaFunctions.py index 9ef80bd3d4..a8b416eeb5 100644 --- a/cura/Settings/CuraFormulaFunctions.py +++ b/cura/Settings/CuraFormulaFunctions.py @@ -42,7 +42,14 @@ class CuraFormulaFunctions: try: extruder_stack = global_stack.extruders[str(extruder_position)] except KeyError: - Logger.log("w", "Value for %s of extruder %s was requested, but that extruder is not available" % (property_key, extruder_position)) + if extruder_position != 0: + Logger.log("w", "Value for %s of extruder %s was requested, but that extruder is not available. Returning the result form extruder 0 instead" % (property_key, extruder_position)) + # This fixes a very specific fringe case; If a profile was created for a custom printer and one of the + # extruder settings has been set to non zero and the profile is loaded for a machine that has only a single extruder + # it would cause all kinds of issues (and eventually a crash). + # See https://github.com/Ultimaker/Cura/issues/5535 + return self.getValueInExtruder(0, property_key, context) + Logger.log("w", "Value for %s of extruder %s was requested, but that extruder is not available. " % (property_key, extruder_position)) return None value = extruder_stack.getRawProperty(property_key, "value", context = context) From 5e66564c00bbdf8acc67b63c4271d3d0b778ff0d Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 2 Apr 2019 12:05:08 +0200 Subject: [PATCH 18/18] Ensure that configurationTypes doesn't crash if a None is in the list Fixes #5551 --- cura/Settings/GlobalStack.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cura/Settings/GlobalStack.py b/cura/Settings/GlobalStack.py index 3940af7ecc..de2273380b 100755 --- a/cura/Settings/GlobalStack.py +++ b/cura/Settings/GlobalStack.py @@ -81,7 +81,15 @@ class GlobalStack(CuraContainerStack): # Requesting it from the metadata actually gets them as strings (as that's what you get from serializing). # But we do want them returned as a list of ints (so the rest of the code can directly compare) connection_types = self.getMetaDataEntry("connection_type", "").split(",") - return [int(connection_type) for connection_type in connection_types if connection_type != ""] + result = [] + for connection_type in connection_types: + if connection_type != "": + try: + result.append(int(connection_type)) + except ValueError: + # We got invalid data, probably a None. + pass + return result ## \sa configuredConnectionTypes def addConfiguredConnectionType(self, connection_type: int) -> None: