From 30a05e6ba6e7af6b498276bcc5b62229c4dd3821 Mon Sep 17 00:00:00 2001 From: Mark Date: Sun, 3 Jun 2018 12:57:08 +0200 Subject: [PATCH 1/4] make sure old plugins are updatable --- plugins/Toolbox/src/Toolbox.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/plugins/Toolbox/src/Toolbox.py b/plugins/Toolbox/src/Toolbox.py index b019dfccbe..99d7ac46c3 100644 --- a/plugins/Toolbox/src/Toolbox.py +++ b/plugins/Toolbox/src/Toolbox.py @@ -169,6 +169,27 @@ class Toolbox(QObject, Extension): "materials_showcase": QUrl("{base_url}/showcase".format(base_url=self._api_url)) } + OLD_PLUGINS = ['3DPrinterOS', + 'BarbarianPlugin', + 'CuraSolidWorksPlugin', + 'MakePrintablePlugin', + 'OctoPrintPlugin', + 'OrientationPlugin', + 'ZOffsetPlugin', + 'cura-siemensnx-plugin'] + + # check for plugins that were installed with the old plugin-browser + def _isOldPlugin(self, plugin_id) -> bool: + if plugin_id in self.OLD_PLUGINS and plugin_id in self._plugin_registry.getInstalledPlugins(): + Logger.log('i', 'Found a plugin that was installed with the old plugin browser: %s', plugin_id) + if not self._package_manager.isPackageInstalled(plugin_id): + Logger.log('i', 'Plugin was not found in package.json: %s', self._package_manager.getInstalledPackageInfo(plugin_id)) + return True + return False + + + + # Get the API root for the packages API depending on Cura version settings. def _getCloudAPIRoot(self) -> str: if not hasattr(cura, "CuraVersion"): @@ -325,6 +346,9 @@ class Toolbox(QObject, Extension): # -------------------------------------------------------------------------- @pyqtSlot(str, result = bool) def canUpdate(self, package_id: str) -> bool: + if self._isOldPlugin(package_id): + return True + local_package = self._package_manager.getInstalledPackageInfo(package_id) if local_package is None: return False @@ -355,7 +379,7 @@ class Toolbox(QObject, Extension): @pyqtSlot(str, result = bool) def isInstalled(self, package_id: str) -> bool: - return self._package_manager.isPackageInstalled(package_id) + return self._package_manager.isPackageInstalled(package_id) or self._isOldPlugin(package_id) @pyqtSlot(str, result = bool) def isEnabled(self, package_id: str) -> bool: From 0e11a165a3a39ec74f1884041e6f3a5734ed817b Mon Sep 17 00:00:00 2001 From: Mark Date: Sun, 3 Jun 2018 18:14:34 +0200 Subject: [PATCH 2/4] add typing --- plugins/Toolbox/src/Toolbox.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/Toolbox/src/Toolbox.py b/plugins/Toolbox/src/Toolbox.py index 99d7ac46c3..4bf04c1e38 100644 --- a/plugins/Toolbox/src/Toolbox.py +++ b/plugins/Toolbox/src/Toolbox.py @@ -179,7 +179,7 @@ class Toolbox(QObject, Extension): 'cura-siemensnx-plugin'] # check for plugins that were installed with the old plugin-browser - def _isOldPlugin(self, plugin_id) -> bool: + def _isOldPlugin(self, plugin_id: str) -> bool: if plugin_id in self.OLD_PLUGINS and plugin_id in self._plugin_registry.getInstalledPlugins(): Logger.log('i', 'Found a plugin that was installed with the old plugin browser: %s', plugin_id) if not self._package_manager.isPackageInstalled(plugin_id): From 096f0775a8e08b3d7bdbb4648307c30c78f709f7 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Mon, 4 Jun 2018 11:49:42 +0200 Subject: [PATCH 3/4] CURA-5442 Compare plugin registry to package manager --- cura/CuraPackageManager.py | 8 +++++- plugins/Toolbox/src/Toolbox.py | 49 +++++++++++++++++----------------- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/cura/CuraPackageManager.py b/cura/CuraPackageManager.py index 096bfc9065..24a7bda267 100644 --- a/cura/CuraPackageManager.py +++ b/cura/CuraPackageManager.py @@ -134,7 +134,7 @@ class CuraPackageManager(QObject): return None - def getAllInstalledPackagesInfo(self) -> dict: + def getAllInstalledPackageIDs(self) -> set: # Add bundled, installed, and to-install packages to the set of installed package IDs all_installed_ids = set() @@ -147,6 +147,12 @@ class CuraPackageManager(QObject): if self._to_install_package_dict.keys(): all_installed_ids = all_installed_ids.union(set(self._to_install_package_dict.keys())) + return all_installed_ids + + def getAllInstalledPackagesInfo(self) -> dict: + + all_installed_ids = self.getAllInstalledPackageIDs() + # map of -> -> installed_packages_dict = {} for package_id in all_installed_ids: diff --git a/plugins/Toolbox/src/Toolbox.py b/plugins/Toolbox/src/Toolbox.py index 4bf04c1e38..9e3adcc789 100644 --- a/plugins/Toolbox/src/Toolbox.py +++ b/plugins/Toolbox/src/Toolbox.py @@ -64,14 +64,17 @@ class Toolbox(QObject, Extension): ] self._request_urls = {} self._to_update = [] # Package_ids that are waiting to be updated + self._old_plugin_ids = [] # Data: self._metadata = { "authors": [], "packages": [], "plugins_showcase": [], + "plugins_available": [], "plugins_installed": [], "materials_showcase": [], + "materials_available": [], "materials_installed": [] } @@ -166,30 +169,11 @@ class Toolbox(QObject, Extension): "authors": QUrl("{base_url}/authors".format(base_url=self._api_url)), "packages": QUrl("{base_url}/packages".format(base_url=self._api_url)), "plugins_showcase": QUrl("{base_url}/showcase".format(base_url=self._api_url)), - "materials_showcase": QUrl("{base_url}/showcase".format(base_url=self._api_url)) + "plugins_available": QUrl("{base_url}/packages?package_type=plugin".format(base_url=self._api_url)), + "materials_showcase": QUrl("{base_url}/showcase".format(base_url=self._api_url)), + "materials_available": QUrl("{base_url}/packages?package_type=material".format(base_url=self._api_url)) } - OLD_PLUGINS = ['3DPrinterOS', - 'BarbarianPlugin', - 'CuraSolidWorksPlugin', - 'MakePrintablePlugin', - 'OctoPrintPlugin', - 'OrientationPlugin', - 'ZOffsetPlugin', - 'cura-siemensnx-plugin'] - - # check for plugins that were installed with the old plugin-browser - def _isOldPlugin(self, plugin_id: str) -> bool: - if plugin_id in self.OLD_PLUGINS and plugin_id in self._plugin_registry.getInstalledPlugins(): - Logger.log('i', 'Found a plugin that was installed with the old plugin browser: %s', plugin_id) - if not self._package_manager.isPackageInstalled(plugin_id): - Logger.log('i', 'Plugin was not found in package.json: %s', self._package_manager.getInstalledPackageInfo(plugin_id)) - return True - return False - - - - # Get the API root for the packages API depending on Cura version settings. def _getCloudAPIRoot(self) -> str: if not hasattr(cura, "CuraVersion"): @@ -256,6 +240,17 @@ class Toolbox(QObject, Extension): @pyqtSlot() def _updateInstalledModels(self) -> None: + + # This is moved here to avoid code duplication and so that after installing plugins they get removed from the + # list of old plugins + old_plugin_ids = self._plugin_registry.getInstalledPlugins() + installed_package_ids = self._package_manager.getAllInstalledPackageIDs() + self._old_plugin_ids = [] + for plugin_id in old_plugin_ids: + if plugin_id not in installed_package_ids: + Logger.log('i', 'Found a plugin that was installed with the old plugin browser: %s', plugin_id) + self._old_plugin_ids.append(plugin_id) + all_packages = self._package_manager.getAllInstalledPackagesInfo() if "plugin" in all_packages: self._metadata["plugins_installed"] = all_packages["plugin"] @@ -346,7 +341,7 @@ class Toolbox(QObject, Extension): # -------------------------------------------------------------------------- @pyqtSlot(str, result = bool) def canUpdate(self, package_id: str) -> bool: - if self._isOldPlugin(package_id): + if self.isOldPlugin(package_id): return True local_package = self._package_manager.getInstalledPackageInfo(package_id) @@ -379,7 +374,7 @@ class Toolbox(QObject, Extension): @pyqtSlot(str, result = bool) def isInstalled(self, package_id: str) -> bool: - return self._package_manager.isPackageInstalled(package_id) or self._isOldPlugin(package_id) + return self._package_manager.isPackageInstalled(package_id) @pyqtSlot(str, result = bool) def isEnabled(self, package_id: str) -> bool: @@ -387,6 +382,12 @@ class Toolbox(QObject, Extension): return True return False + # Check for plugins that were installed with the old plugin browser + def isOldPlugin(self, plugin_id: str) -> bool: + if plugin_id in self._old_plugin_ids: + return True + return False + def loadingComplete(self) -> bool: populated = 0 for list in self._metadata.items(): From 71f41b8ada7fd0cdaebcc0c6fdf54f1bdacd622d Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Mon, 4 Jun 2018 17:00:59 +0200 Subject: [PATCH 4/4] CURA-5442 Final fixes --- .../qml/ToolboxDetailTileActions.qml | 3 +- plugins/Toolbox/src/Toolbox.py | 29 +- resources/bundled_packages.json | 272 ++++++++++++++++++ 3 files changed, 302 insertions(+), 2 deletions(-) diff --git a/plugins/Toolbox/resources/qml/ToolboxDetailTileActions.qml b/plugins/Toolbox/resources/qml/ToolboxDetailTileActions.qml index f82fb049d8..cd1e4cdbda 100644 --- a/plugins/Toolbox/resources/qml/ToolboxDetailTileActions.qml +++ b/plugins/Toolbox/resources/qml/ToolboxDetailTileActions.qml @@ -34,6 +34,7 @@ Column // Don't allow installing while another download is running enabled: installed || !(toolbox.isDownloading && toolbox.activePackage != model) opacity: enabled ? 1.0 : 0.5 + visible: !updateButton.visible // Don't show when the update button is visible } ToolboxProgressButton @@ -55,7 +56,7 @@ Column // Don't allow installing while another download is running enabled: !(toolbox.isDownloading && toolbox.activePackage != model) opacity: enabled ? 1.0 : 0.5 - visible: installed && canUpdate + visible: canUpdate } Connections { diff --git a/plugins/Toolbox/src/Toolbox.py b/plugins/Toolbox/src/Toolbox.py index 9e3adcc789..b9264b89df 100644 --- a/plugins/Toolbox/src/Toolbox.py +++ b/plugins/Toolbox/src/Toolbox.py @@ -238,6 +238,23 @@ class Toolbox(QObject, Extension): dialog = Application.getInstance().createQmlComponent(path, {"toolbox": self}) return dialog + + def _convertPluginMetadata(self, plugin: dict) -> dict: + formatted = { + "package_id": plugin["id"], + "package_type": "plugin", + "display_name": plugin["plugin"]["name"], + "package_version": plugin["plugin"]["version"], + "sdk_version": plugin["plugin"]["api"], + "author": { + "author_id": plugin["plugin"]["author"], + "display_name": plugin["plugin"]["author"] + }, + "is_installed": True, + "description": plugin["plugin"]["description"] + } + return formatted + @pyqtSlot() def _updateInstalledModels(self) -> None: @@ -245,19 +262,28 @@ class Toolbox(QObject, Extension): # list of old plugins old_plugin_ids = self._plugin_registry.getInstalledPlugins() installed_package_ids = self._package_manager.getAllInstalledPackageIDs() + self._old_plugin_ids = [] + self._old_plugin_metadata = [] + for plugin_id in old_plugin_ids: if plugin_id not in installed_package_ids: Logger.log('i', 'Found a plugin that was installed with the old plugin browser: %s', plugin_id) + + old_metadata = self._plugin_registry.getMetaData(plugin_id) + new_metadata = self._convertPluginMetadata(old_metadata) + self._old_plugin_ids.append(plugin_id) + self._old_plugin_metadata.append(new_metadata) all_packages = self._package_manager.getAllInstalledPackagesInfo() if "plugin" in all_packages: - self._metadata["plugins_installed"] = all_packages["plugin"] + self._metadata["plugins_installed"] = all_packages["plugin"] + self._old_plugin_metadata self._models["plugins_installed"].setMetadata(self._metadata["plugins_installed"]) self.metadataChanged.emit() if "material" in all_packages: self._metadata["materials_installed"] = all_packages["material"] + # TODO: ADD MATERIALS HERE ONCE MATERIALS PORTION OF TOOLBOX IS LIVE self._models["materials_installed"].setMetadata(self._metadata["materials_installed"]) self.metadataChanged.emit() @@ -383,6 +409,7 @@ class Toolbox(QObject, Extension): return False # Check for plugins that were installed with the old plugin browser + @pyqtSlot(str, result = bool) def isOldPlugin(self, plugin_id: str) -> bool: if plugin_id in self._old_plugin_ids: return True diff --git a/resources/bundled_packages.json b/resources/bundled_packages.json index ab6bf7e925..7f3ba2a92e 100644 --- a/resources/bundled_packages.json +++ b/resources/bundled_packages.json @@ -1132,5 +1132,277 @@ "website": "https://www.vellemanprojects.eu" } } + }, + "ConsoleLogger": { + "package_info": { + "package_id": "ConsoleLogger", + "package_type": "plugin", + "display_name": "Console Logger", + "description": "Outputs log information to the console.", + "package_version": "1.0.0", + "sdk_version": 4, + "website": "https://ultimaker.com", + "author": { + "author_id": "Ultimaker", + "display_name": "Ultimaker B.V.", + "email": "plugins@ultimaker.com", + "website": "https://ultimaker.com" + } + } + }, + "OBJReader": { + "package_info": { + "package_id": "OBJReader", + "package_type": "plugin", + "display_name": "Wavefront OBJ Reader", + "description": "Makes it possible to read Wavefront OBJ files.", + "package_version": "1.0.0", + "sdk_version": 4, + "website": "https://ultimaker.com", + "author": { + "author_id": "Ultimaker", + "display_name": "Ultimaker B.V.", + "email": "plugins@ultimaker.com", + "website": "https://ultimaker.com" + } + } + }, + "OBJWriter": { + "package_info": { + "package_id": "OBJWriter", + "package_type": "plugin", + "display_name": "Wavefront OBJ Writer", + "description": "Makes it possible to write Wavefront OBJ files.", + "package_version": "1.0.0", + "sdk_version": 4, + "website": "https://ultimaker.com", + "author": { + "author_id": "Ultimaker", + "display_name": "Ultimaker B.V.", + "email": "plugins@ultimaker.com", + "website": "https://ultimaker.com" + } + } + }, + "STLReader": { + "package_info": { + "package_id": "STLReader", + "package_type": "plugin", + "display_name": "STL Reader", + "description": "Provides support for reading STL files.", + "package_version": "1.0.0", + "sdk_version": 4, + "website": "https://ultimaker.com", + "author": { + "author_id": "Ultimaker", + "display_name": "Ultimaker B.V.", + "email": "plugins@ultimaker.com", + "website": "https://ultimaker.com" + } + } + }, + "STLWriter": { + "package_info": { + "package_id": "STLWriter", + "package_type": "plugin", + "display_name": "STL Writer", + "description": "Provides support for writing STL files.", + "package_version": "1.0.0", + "sdk_version": 4, + "website": "https://ultimaker.com", + "author": { + "author_id": "Ultimaker", + "display_name": "Ultimaker B.V.", + "email": "plugins@ultimaker.com", + "website": "https://ultimaker.com" + } + } + }, + "FileLogger": { + "package_info": { + "package_id": "FileLogger", + "package_type": "plugin", + "display_name": "File Logger", + "description": "Outputs log information to a file in your settings folder.", + "package_version": "1.0.0", + "sdk_version": 4, + "website": "https://ultimaker.com", + "author": { + "author_id": "Ultimaker", + "display_name": "Ultimaker B.V.", + "email": "plugins@ultimaker.com", + "website": "https://ultimaker.com" + } + } + }, + "LocalContainerProvider": { + "package_info": { + "package_id": "LocalContainerProvider", + "package_type": "plugin", + "display_name": "Local Container Provider", + "description": "Provides built-in setting containers that come with the installation of the application.", + "package_version": "1.0.0", + "sdk_version": 4, + "website": "https://ultimaker.com", + "author": { + "author_id": "Ultimaker", + "display_name": "Ultimaker B.V.", + "email": "plugins@ultimaker.com", + "website": "https://ultimaker.com" + } + } + }, + "LocalFileOutputDevice": { + "package_info": { + "package_id": "LocalFileOutputDevice", + "package_type": "plugin", + "display_name": "Local File Output Device", + "description": "Enables saving to local files.", + "package_version": "1.0.0", + "sdk_version": 4, + "website": "https://ultimaker.com", + "author": { + "author_id": "Ultimaker", + "display_name": "Ultimaker B.V.", + "email": "plugins@ultimaker.com", + "website": "https://ultimaker.com" + } + } + }, + "CameraTool": { + "package_info": { + "package_id": "CameraTool", + "package_type": "plugin", + "display_name": "Camera Tool", + "description": "Provides the tool to manipulate the camera.", + "package_version": "1.0.0", + "sdk_version": 4, + "website": "https://ultimaker.com", + "author": { + "author_id": "Ultimaker", + "display_name": "Ultimaker B.V.", + "email": "plugins@ultimaker.com", + "website": "https://ultimaker.com" + } + } + }, + "MirrorTool": { + "package_info": { + "package_id": "MirrorTool", + "package_type": "plugin", + "display_name": "Mirror Tool", + "description": "Provides the Mirror tool.", + "package_version": "1.0.0", + "sdk_version": 4, + "website": "https://ultimaker.com", + "author": { + "author_id": "Ultimaker", + "display_name": "Ultimaker B.V.", + "email": "plugins@ultimaker.com", + "website": "https://ultimaker.com" + } + } + }, + "RotateTool": { + "package_info": { + "package_id": "RotateTool", + "package_type": "plugin", + "display_name": "Rotate Tool", + "description": "Provides the Rotate tool.", + "package_version": "1.0.0", + "sdk_version": 4, + "website": "https://ultimaker.com", + "author": { + "author_id": "Ultimaker", + "display_name": "Ultimaker B.V.", + "email": "plugins@ultimaker.com", + "website": "https://ultimaker.com" + } + } + }, + "ScaleTool": { + "package_info": { + "package_id": "ScaleTool", + "package_type": "plugin", + "display_name": "Scale Tool", + "description": "Provides the Scale tool.", + "package_version": "1.0.0", + "sdk_version": 4, + "website": "https://ultimaker.com", + "author": { + "author_id": "Ultimaker", + "display_name": "Ultimaker B.V.", + "email": "plugins@ultimaker.com", + "website": "https://ultimaker.com" + } + } + }, + "SelectionTool": { + "package_info": { + "package_id": "SelectionTool", + "package_type": "plugin", + "display_name": "Selection Tool", + "description": "Provides the Selection tool.", + "package_version": "1.0.0", + "sdk_version": 4, + "website": "https://ultimaker.com", + "author": { + "author_id": "Ultimaker", + "display_name": "Ultimaker B.V.", + "email": "plugins@ultimaker.com", + "website": "https://ultimaker.com" + } + } + }, + "TranslateTool": { + "package_info": { + "package_id": "TranslateTool", + "package_type": "plugin", + "display_name": "Move Tool", + "description": "Provides the Move tool.", + "package_version": "1.0.0", + "sdk_version": 4, + "website": "https://ultimaker.com", + "author": { + "author_id": "Ultimaker", + "display_name": "Ultimaker B.V.", + "email": "plugins@ultimaker.com", + "website": "https://ultimaker.com" + } + } + }, + "UpdateChecker": { + "package_info": { + "package_id": "UpdateChecker", + "package_type": "plugin", + "display_name": "Update Checker", + "description": "Checks for updates of the software.", + "package_version": "1.0.0", + "sdk_version": 4, + "website": "https://ultimaker.com", + "author": { + "author_id": "Ultimaker", + "display_name": "Ultimaker B.V.", + "email": "plugins@ultimaker.com", + "website": "https://ultimaker.com" + } + } + }, + "SimpleView": { + "package_info": { + "package_id": "SimpleView", + "package_type": "plugin", + "display_name": "Simple View", + "description": "Provides a simple solid mesh view.", + "package_version": "1.0.0", + "sdk_version": 4, + "website": "https://ultimaker.com", + "author": { + "author_id": "Ultimaker", + "display_name": "Ultimaker B.V.", + "email": "plugins@ultimaker.com", + "website": "https://ultimaker.com" + } + } } }