def setUp(self): super().setUp() self.app = MagicMock() self.device_manager = OutputDeviceManager() self.app.getOutputDeviceManager.return_value = self.device_manager self.patches = [ patch("UM.Qt.QtApplication.QtApplication.getInstance", return_value=self.app), patch("UM.Application.Application.getInstance", return_value=self.app) ] for patched_method in self.patches: patched_method.start() self.network = NetworkManagerMock() self.timer = MagicMock(timeout=FakeSignal()) with patch.object(CloudApiClient, "QNetworkAccessManager", return_value = self.network), \ patch.object(CloudOutputDeviceManager, "QTimer", return_value = self.timer): self.manager = CloudOutputDeviceManager.CloudOutputDeviceManager() self.clusters_response = parseFixture("getClusters") self.network.prepareReply("GET", self.URL, 200, readFixture("getClusters"))
def setUp(self): super().setUp() self.app = MagicMock() self.device_manager = OutputDeviceManager() self.app.getOutputDeviceManager.return_value = self.device_manager self.patches = [patch("UM.Qt.QtApplication.QtApplication.getInstance", return_value=self.app), patch("UM.Application.Application.getInstance", return_value=self.app)] for patched_method in self.patches: patched_method.start() self.network = NetworkManagerMock() self.timer = MagicMock(timeout = FakeSignal()) with patch.object(CloudApiClient, "QNetworkAccessManager", return_value = self.network), \ patch.object(CloudOutputDeviceManager, "QTimer", return_value = self.timer): self.manager = CloudOutputDeviceManager.CloudOutputDeviceManager() self.clusters_response = parseFixture("getClusters") self.network.prepareReply("GET", self.URL, 200, readFixture("getClusters"))
def initialize(self) -> None: # For Ubuntu Unity this makes Qt use its own menu bar rather than pass it on to Unity. os.putenv("UBUNTU_MENUPROXY", "0") # Custom signal handling Signal._app = self Signal._signalQueue = self # Initialize Resources. Set the application name and version here because we can only know the actual info # after the __init__() has been called. Resources.ApplicationIdentifier = self._app_name Resources.ApplicationVersion = self._version Resources.addSearchPath( os.path.join(os.path.dirname(sys.executable), "resources")) Resources.addSearchPath( os.path.join(self._app_install_dir, "share", "uranium", "resources")) Resources.addSearchPath( os.path.join(self._app_install_dir, "Resources", "uranium", "resources")) Resources.addSearchPath( os.path.join(self._app_install_dir, "Resources", self._app_name, "resources")) if not hasattr(sys, "frozen"): Resources.addSearchPath( os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "resources")) i18nCatalog.setApplication(self) PluginRegistry.addType("backend", self.setBackend) PluginRegistry.addType("logger", Logger.addLogger) PluginRegistry.addType("extension", self.addExtension) self._preferences = Preferences() self._preferences.addPreference("general/language", self._default_language) self._preferences.addPreference("general/visible_settings", "") self._preferences.addPreference("general/plugins_to_remove", "") self._preferences.addPreference("general/disabled_plugins", "") self._controller = Controller(self) self._output_device_manager = OutputDeviceManager() self._operation_stack = OperationStack( self._controller) # type: OperationStack self._plugin_registry = PluginRegistry(self) #type: PluginRegistry self._plugin_registry.addPluginLocation( os.path.join(self._app_install_dir, "lib", "uranium")) self._plugin_registry.addPluginLocation( os.path.join(self._app_install_dir, "lib64", "uranium")) self._plugin_registry.addPluginLocation( os.path.join(self._app_install_dir, "lib32", "uranium")) self._plugin_registry.addPluginLocation( os.path.join(os.path.dirname(sys.executable), "plugins")) self._plugin_registry.addPluginLocation( os.path.join(self._app_install_dir, "Resources", "uranium", "plugins")) self._plugin_registry.addPluginLocation( os.path.join(self._app_install_dir, "Resources", self._app_name, "plugins")) # Locally installed plugins local_path = os.path.join( Resources.getStoragePath(Resources.Resources), "plugins") # Ensure the local plugins directory exists try: os.makedirs(local_path) except OSError: pass self._plugin_registry.addPluginLocation(local_path) if not hasattr(sys, "frozen"): self._plugin_registry.addPluginLocation( os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "plugins")) self._container_registry = self._container_registry_class(self) UM.Settings.InstanceContainer.setContainerRegistry( self._container_registry) UM.Settings.ContainerStack.setContainerRegistry( self._container_registry) # Initialize the package manager to remove and install scheduled packages. self._package_manager = self._package_manager_class(self) self.showMessageSignal.connect(self.showMessage) self.hideMessageSignal.connect(self.hideMessage)
class TestCloudOutputDeviceManager(TestCase): maxDiff = None URL = CuraCloudAPIRoot + "/connect/v1/clusters" def setUp(self): super().setUp() self.app = MagicMock() self.device_manager = OutputDeviceManager() self.app.getOutputDeviceManager.return_value = self.device_manager self.patches = [patch("UM.Qt.QtApplication.QtApplication.getInstance", return_value=self.app), patch("UM.Application.Application.getInstance", return_value=self.app)] for patched_method in self.patches: patched_method.start() self.network = NetworkManagerMock() self.timer = MagicMock(timeout = FakeSignal()) with patch.object(CloudApiClient, "QNetworkAccessManager", return_value = self.network), \ patch.object(CloudOutputDeviceManager, "QTimer", return_value = self.timer): self.manager = CloudOutputDeviceManager.CloudOutputDeviceManager() self.clusters_response = parseFixture("getClusters") self.network.prepareReply("GET", self.URL, 200, readFixture("getClusters")) def tearDown(self): try: self._beforeTearDown() self.network.flushReplies() self.manager.stop() for patched_method in self.patches: patched_method.stop() finally: super().tearDown() ## Before tear down method we check whether the state of the output device manager is what we expect based on the # mocked API response. def _beforeTearDown(self): # let the network send replies self.network.flushReplies() # get the created devices devices = self.device_manager.getOutputDevices() # TODO: Check active device response_clusters = self.clusters_response.get("data", []) 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) ## Runs the initial request to retrieve the clusters. def _loadData(self): self.manager.start() self.network.flushReplies() def test_device_is_created(self): # just create the cluster, it is checked at tearDown self._loadData() def test_device_is_updated(self): self._loadData() # update the cluster from member variable, which is checked at tearDown self.clusters_response["data"][0]["host_name"] = "New host name" self.network.prepareReply("GET", self.URL, 200, self.clusters_response) self.manager._update_timer.timeout.emit() def test_device_is_removed(self): self._loadData() # delete the cluster from member variable, which is checked at tearDown del self.clusters_response["data"][1] self.network.prepareReply("GET", self.URL, 200, self.clusters_response) self.manager._update_timer.timeout.emit() def test_device_connects_by_cluster_id(self): active_machine_mock = self.app.getGlobalContainerStack.return_value cluster1, cluster2 = self.clusters_response["data"] cluster_id = cluster1["cluster_id"] active_machine_mock.getMetaDataEntry.side_effect = {"um_cloud_cluster_id": cluster_id}.get self._loadData() 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) def test_device_connects_by_network_key(self): active_machine_mock = self.app.getGlobalContainerStack.return_value cluster1, cluster2 = self.clusters_response["data"] network_key = cluster2["host_name"] + ".ultimaker.local" 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 = { "errors": [{"id": "notFound", "title": "Not found!", "http_status": "404", "code": "notFound"}] } self.network.prepareReply("GET", self.URL, 200, self.clusters_response) self._loadData() message_mock.return_value.show.assert_called_once_with()
def __init__(self, name, version, **kwargs): if (Application._instance != None): raise ValueError("Duplicate singleton creation") # If the constructor is called and there is no instance, set the instance to self. # This is done because we can't make constructor private Application._instance = self self._application_name = name self._version = version os.putenv( "UBUNTU_MENUPROXY", "0" ) #For Ubuntu Unity this makes Qt use its own menu bar rather than pass it on to Unity. Signal._app = self Resources.ApplicationIdentifier = name i18nCatalog.setApplication(self) Resources.addSearchPath(os.path.dirname(sys.executable)) Resources.addSearchPath( os.path.join(Application.getInstallPrefix(), "share", "uranium")) Resources.addSearchPath( os.path.join(Application.getInstallPrefix(), "Resources", "uranium")) Resources.addSearchPath( os.path.join(Application.getInstallPrefix(), "Resources", self.getApplicationName())) if not hasattr(sys, "frozen"): Resources.addSearchPath( os.path.join(os.path.abspath(os.path.dirname(__file__)), "..")) self._main_thread = threading.current_thread() super().__init__( **kwargs) # Call super to make multiple inheritence work. self._renderer = None PluginRegistry.addType("backend", self.setBackend) PluginRegistry.addType("logger", Logger.addLogger) PluginRegistry.addType("extension", self.addExtension) preferences = Preferences.getInstance() preferences.addPreference("general/language", "en") try: preferences.readFromFile( Resources.getPath(Resources.Preferences, self._application_name + ".cfg")) except FileNotFoundError: pass self._controller = Controller(self) self._mesh_file_handler = MeshFileHandler() self._extensions = [] self._backend = None self._output_device_manager = OutputDeviceManager() self._machine_manager = MachineManager(self._application_name) self._required_plugins = [] self._operation_stack = OperationStack() self._plugin_registry = PluginRegistry.getInstance() self._plugin_registry.addPluginLocation( os.path.join(Application.getInstallPrefix(), "lib", "uranium")) self._plugin_registry.addPluginLocation( os.path.join(os.path.dirname(sys.executable), "plugins")) self._plugin_registry.addPluginLocation( os.path.join(Application.getInstallPrefix(), "Resources", "uranium", "plugins")) self._plugin_registry.addPluginLocation( os.path.join(Application.getInstallPrefix(), "Resources", self.getApplicationName(), "plugins")) # Locally installed plugins self._plugin_registry.addPluginLocation( os.path.join(Resources.getStoragePath(Resources.Resources), "plugins")) if not hasattr(sys, "frozen"): self._plugin_registry.addPluginLocation( os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "plugins")) self._plugin_registry.setApplication(self) self._parsed_command_line = None self.parseCommandLine() self._visible_messages = [] self._message_lock = threading.Lock() self.showMessageSignal.connect(self.showMessage) self.hideMessageSignal.connect(self.hideMessage)
def test_addRemoveOutputDevice(): manager = OutputDeviceManager() manager.outputDevicesChanged.emit = MagicMock() manager.activeDeviceChanged.emit = MagicMock() output_device = OutputDevice("test_device_one") output_device.setPriority(2) output_device_2 = OutputDevice("test_device_two") output_device_2.setPriority(9001) manager.addOutputDevice(output_device) assert manager.outputDevicesChanged.emit.call_count == 1 assert manager.getOutputDevice("test_device_one") == output_device # Our new device is also the one with the highest priority (as it's the only one). So it should be active. assert manager.getActiveDevice() == output_device manager.addOutputDevice(output_device) assert manager.outputDevicesChanged.emit.call_count == 1 manager.addOutputDevice(output_device_2) assert manager.outputDevicesChanged.emit.call_count == 2 # We added a new device with a higher priority, so that one should be the active one assert manager.getActiveDevice() == output_device_2 assert set([output_device, output_device_2]) == set(manager.getOutputDevices()) assert set(["test_device_one", "test_device_two"]) == set(manager.getOutputDeviceIds()) # Try to manually change the active device a few times manager.setActiveDevice("test_device_one") assert manager.activeDeviceChanged.emit.call_count == 3 assert manager.getActiveDevice() == output_device manager.setActiveDevice("test_device_two") assert manager.activeDeviceChanged.emit.call_count == 4 assert manager.getActiveDevice() == output_device_2 # As usual, doing it twice shouldn't cause more updates manager.setActiveDevice("test_device_two") assert manager.activeDeviceChanged.emit.call_count == 4 manager.setActiveDevice("Whatever") # Simply shouldn't cause issues. # Time to remove the device again assert manager.removeOutputDevice("test_device_two") assert manager.getActiveDevice() == output_device assert manager.outputDevicesChanged.emit.call_count == 3 # Trying to remove it again should return false assert not manager.removeOutputDevice("test_device_two") assert manager.outputDevicesChanged.emit.call_count == 3
class TestCloudOutputDeviceManager(TestCase): maxDiff = None URL = CuraCloudAPIRoot + "/connect/v1/clusters" def setUp(self): super().setUp() self.app = MagicMock() self.device_manager = OutputDeviceManager() self.app.getOutputDeviceManager.return_value = self.device_manager self.patches = [ patch("UM.Qt.QtApplication.QtApplication.getInstance", return_value=self.app), patch("UM.Application.Application.getInstance", return_value=self.app) ] for patched_method in self.patches: patched_method.start() self.network = NetworkManagerMock() self.timer = MagicMock(timeout=FakeSignal()) with patch.object(CloudApiClient, "QNetworkAccessManager", return_value = self.network), \ patch.object(CloudOutputDeviceManager, "QTimer", return_value = self.timer): self.manager = CloudOutputDeviceManager.CloudOutputDeviceManager() self.clusters_response = parseFixture("getClusters") self.network.prepareReply("GET", self.URL, 200, readFixture("getClusters")) def tearDown(self): try: self._beforeTearDown() self.network.flushReplies() self.manager.stop() for patched_method in self.patches: patched_method.stop() finally: super().tearDown() ## Before tear down method we check whether the state of the output device manager is what we expect based on the # mocked API response. def _beforeTearDown(self): # let the network send replies self.network.flushReplies() # get the created devices devices = self.device_manager.getOutputDevices() # TODO: Check active device response_clusters = self.clusters_response.get("data", []) 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) ## Runs the initial request to retrieve the clusters. def _loadData(self): self.manager.start() self.network.flushReplies() def test_device_is_created(self): # just create the cluster, it is checked at tearDown self._loadData() def test_device_is_updated(self): self._loadData() # update the cluster from member variable, which is checked at tearDown self.clusters_response["data"][0]["host_name"] = "New host name" self.network.prepareReply("GET", self.URL, 200, self.clusters_response) self.manager._update_timer.timeout.emit() def test_device_is_removed(self): self._loadData() # delete the cluster from member variable, which is checked at tearDown del self.clusters_response["data"][1] self.network.prepareReply("GET", self.URL, 200, self.clusters_response) self.manager._update_timer.timeout.emit() def test_device_connects_by_cluster_id(self): active_machine_mock = self.app.getGlobalContainerStack.return_value cluster1, cluster2 = self.clusters_response["data"] cluster_id = cluster1["cluster_id"] active_machine_mock.getMetaDataEntry.side_effect = { "um_cloud_cluster_id": cluster_id }.get self._loadData() 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) def test_device_connects_by_network_key(self): active_machine_mock = self.app.getGlobalContainerStack.return_value cluster1, cluster2 = self.clusters_response["data"] network_key = cluster2["host_name"] + ".ultimaker.local" 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 = { "errors": [{ "id": "notFound", "title": "Not found!", "http_status": "404", "code": "notFound" }] } self.network.prepareReply("GET", self.URL, 200, self.clusters_response) self._loadData() message_mock.return_value.show.assert_called_once_with()
def test_addRemoveOutputDevicePlugin(): manager = OutputDeviceManager() plugin_1 = OutputDevicePlugin() plugin_1.setPluginId("plugin_one") plugin_1.start = MagicMock() plugin_1.stop = MagicMock() manager.addOutputDevicePlugin(plugin_1) assert manager.getOutputDevicePlugin("plugin_one") == plugin_1 assert plugin_1.start.call_count == 1 # adding it again shouldn't cause the start to be called again! manager.addOutputDevicePlugin(plugin_1) assert plugin_1.start.call_count == 1 manager.removeOutputDevicePlugin("plugin_one") assert manager.getOutputDevicePlugin("plugin_one") is None assert plugin_1.start.call_count == 1 # And removing it again shouldn't cause issues. manager.removeOutputDevicePlugin("plugin_two") assert plugin_1.start.call_count == 1 # As the default output device plugin is an interface, the start and stop will raise exceptions. # but the outputdevice manager should be robust against that, so even in that case it shouldn't fail! plugin_2 = OutputDevicePlugin() plugin_2.setPluginId("plugin_two") manager.addOutputDevicePlugin(plugin_2) manager.removeOutputDevicePlugin("plugin_two")
def __init__(self, name: str, version: str, build_type: str = "", is_debug_mode: bool = False, parser: argparse.ArgumentParser = None, parsed_command_line: Dict[str, Any] = None, **kwargs) -> None: if Application._instance is not None: raise ValueError("Duplicate singleton creation") if parsed_command_line is None: parsed_command_line = {} # If the constructor is called and there is no instance, set the instance to self. # This is done because we can't make constructor private Application._instance = self self._application_name = name #type: str self._version = version #type: str self._build_type = build_type #type: str if "debug" in parsed_command_line.keys(): if not parsed_command_line["debug"] and is_debug_mode: parsed_command_line["debug"] = is_debug_mode os.putenv("UBUNTU_MENUPROXY", "0") # For Ubuntu Unity this makes Qt use its own menu bar rather than pass it on to Unity. Signal._app = self Signal._signalQueue = self Resources.ApplicationIdentifier = name Resources.ApplicationVersion = version Resources.addSearchPath(os.path.join(os.path.dirname(sys.executable), "resources")) Resources.addSearchPath(os.path.join(Application.getInstallPrefix(), "share", "uranium", "resources")) Resources.addSearchPath(os.path.join(Application.getInstallPrefix(), "Resources", "uranium", "resources")) Resources.addSearchPath(os.path.join(Application.getInstallPrefix(), "Resources", self.getApplicationName(), "resources")) if not hasattr(sys, "frozen"): Resources.addSearchPath(os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "resources")) self._main_thread = threading.current_thread() #type: threading.Thread super().__init__() # Call super to make multiple inheritance work. i18nCatalog.setApplication(self) self._renderer = None #type: Renderer PluginRegistry.addType("backend", self.setBackend) PluginRegistry.addType("logger", Logger.addLogger) PluginRegistry.addType("extension", self.addExtension) self.default_theme = self.getApplicationName() #type: str preferences = Preferences.getInstance() preferences.addPreference("general/language", "en_US") preferences.addPreference("general/visible_settings", "") preferences.addPreference("general/plugins_to_remove", "") preferences.addPreference("general/disabled_plugins", "") try: preferences.readFromFile(Resources.getPath(Resources.Preferences, self._application_name + ".cfg")) except FileNotFoundError: pass self._controller = Controller(self) #type: Controller self._extensions = [] #type: List[Extension] self._backend = None #type: Backend self._output_device_manager = OutputDeviceManager() #type: OutputDeviceManager self._required_plugins = [] #type: List[str] self._operation_stack = OperationStack(self.getController()) #type: OperationStack self._plugin_registry = PluginRegistry.getInstance() #type: PluginRegistry self._plugin_registry.addPluginLocation(os.path.join(Application.getInstallPrefix(), UraniumLibraryDir, "uranium")) self._plugin_registry.addPluginLocation(os.path.join(os.path.dirname(sys.executable), "plugins")) self._plugin_registry.addPluginLocation(os.path.join(Application.getInstallPrefix(), "Resources", "uranium", "plugins")) self._plugin_registry.addPluginLocation(os.path.join(Application.getInstallPrefix(), "Resources", self.getApplicationName(), "plugins")) # Locally installed plugins local_path = os.path.join(Resources.getStoragePath(Resources.Resources), "plugins") # Ensure the local plugins directory exists try: os.makedirs(local_path) except OSError: pass self._plugin_registry.addPluginLocation(local_path) if not hasattr(sys, "frozen"): self._plugin_registry.addPluginLocation(os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "plugins")) self._plugin_registry.setApplication(self) ContainerRegistry.setApplication(self) UM.Settings.InstanceContainer.setContainerRegistry(self.getContainerRegistry()) UM.Settings.ContainerStack.setContainerRegistry(self.getContainerRegistry()) self._command_line_parser = parser #type: argparse.ArgumentParser self._parsed_command_line = parsed_command_line #type: Dict[str, Any] self.parseCommandLine() self._visible_messages = [] #type: List[Message] self._message_lock = threading.Lock() #type: threading.Lock self.showMessageSignal.connect(self.showMessage) self.hideMessageSignal.connect(self.hideMessage) self._global_container_stack = None #type: ContainerStack
def test_addRemoveOutputDevicePlugin(): manager = OutputDeviceManager() plugin_1 = OutputDevicePlugin() plugin_1.setPluginId("plugin_one") plugin_1.start = MagicMock() plugin_1.stop = MagicMock() manager.addOutputDevicePlugin(plugin_1) assert manager.getOutputDevicePlugin("plugin_one") == plugin_1 # Outputdevice manager wasn't started, so the start of the plugin should not be called assert plugin_1.start.call_count == 0 # So once we do, it should be called. manager.start() assert plugin_1.start.call_count == 1 # Adding it again shouldn't cause the start to be called again! manager.addOutputDevicePlugin(plugin_1) assert plugin_1.start.call_count == 1 manager.removeOutputDevicePlugin("plugin_one") assert manager.getOutputDevicePlugin("plugin_one") is None assert plugin_1.start.call_count == 1 # And removing it again shouldn't cause issues. manager.removeOutputDevicePlugin("plugin_two") assert plugin_1.start.call_count == 1 # As the default output device plugin is an interface, the start and stop will raise exceptions. # but the outputdevice manager should be robust against that, so even in that case it shouldn't fail! plugin_2 = OutputDevicePlugin() plugin_2.setPluginId("plugin_two") manager.addOutputDevicePlugin(plugin_2) manager.removeOutputDevicePlugin("plugin_two")
def __init__(self, name: str, version: str, build_type: str = "", **kwargs): if Application._instance != None: raise ValueError("Duplicate singleton creation") # If the constructor is called and there is no instance, set the instance to self. # This is done because we can't make constructor private Application._instance = self self._application_name = name self._version = version self._build_type = build_type os.putenv("UBUNTU_MENUPROXY", "0") # For Ubuntu Unity this makes Qt use its own menu bar rather than pass it on to Unity. Signal._app = self Signal._signalQueue = self Resources.ApplicationIdentifier = name Resources.ApplicationVersion = version Resources.addSearchPath(os.path.join(os.path.dirname(sys.executable), "resources")) Resources.addSearchPath(os.path.join(Application.getInstallPrefix(), "share", "uranium", "resources")) Resources.addSearchPath(os.path.join(Application.getInstallPrefix(), "Resources", "uranium", "resources")) Resources.addSearchPath(os.path.join(Application.getInstallPrefix(), "Resources", self.getApplicationName(), "resources")) #Fixme:CuraApplication will add the path again, so comment this # if not hasattr(sys, "frozen"): # Resources.addSearchPath(os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "resources")) self._main_thread = threading.current_thread() super().__init__() # Call super to make multiple inheritance work. i18nCatalog.setApplication(self) self._renderer = None PluginRegistry.addType("backend", self.setBackend) PluginRegistry.addType("logger", Logger.addLogger) PluginRegistry.addType("extension", self.addExtension) preferences = Preferences.getInstance() preferences.addPreference("general/language", "en") preferences.addPreference("general/visible_settings", "") try: preferences.readFromFile(Resources.getPath(Resources.Preferences, self._application_name + ".cfg")) except FileNotFoundError: pass self._controller = Controller(self) self._mesh_file_handler = MeshFileHandler.getInstance() self._mesh_file_handler.setApplication(self) self._workspace_file_handler = WorkspaceFileHandler.getInstance() self._workspace_file_handler.setApplication(self) self._extensions = [] self._backend = None self._output_device_manager = OutputDeviceManager() self._required_plugins = [] self._operation_stack = OperationStack(self.getController()) self._plugin_registry = PluginRegistry.getInstance() self._plugin_registry.addPluginLocation(os.path.join(Application.getInstallPrefix(), "lib", "uranium")) self._plugin_registry.addPluginLocation(os.path.join(os.path.dirname(sys.executable), "plugins")) self._plugin_registry.addPluginLocation(os.path.join(Application.getInstallPrefix(), "Resources", "uranium", "plugins")) self._plugin_registry.addPluginLocation(os.path.join(Application.getInstallPrefix(), "Resources", self.getApplicationName(), "plugins")) # Locally installed plugins local_path = os.path.join(Resources.getStoragePath(Resources.Resources), "plugins") # Ensure the local plugins directory exists try: os.makedirs(local_path) except OSError: pass self._plugin_registry.addPluginLocation(local_path) # Fixme:CuraApplication will add the path again, so comment this # if not hasattr(sys, "frozen"): # self._plugin_registry.addPluginLocation(os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "plugins")) self._plugin_registry.setApplication(self) ContainerRegistry.setApplication(self) UM.Settings.InstanceContainer.setContainerRegistry(self.getContainerRegistry()) UM.Settings.ContainerStack.setContainerRegistry(self.getContainerRegistry()) self._parsed_command_line = None self.parseCommandLine() self._visible_messages = [] self._message_lock = threading.Lock() self.showMessageSignal.connect(self.showMessage) self.hideMessageSignal.connect(self.hideMessage) self._global_container_stack = None