From 44954c4cadf43cee719c03157f3edd5fff397abb Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 1 Nov 2018 14:15:16 +0100 Subject: [PATCH 1/3] Fixes required for semantic versioning CURA-5840 --- plugins/Toolbox/src/Toolbox.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/Toolbox/src/Toolbox.py b/plugins/Toolbox/src/Toolbox.py index 25e7656999..7db4e8bde0 100644 --- a/plugins/Toolbox/src/Toolbox.py +++ b/plugins/Toolbox/src/Toolbox.py @@ -209,11 +209,11 @@ class Toolbox(QObject, Extension): # Get the packages version depending on Cura version settings. def _getSDKVersion(self) -> Union[int, str]: if not hasattr(cura, "CuraVersion"): - return self._plugin_registry.APIVersion + return self._plugin_registry.APIVersion.getMajor() if not hasattr(cura.CuraVersion, "CuraSDKVersion"): # type: ignore - return self._plugin_registry.APIVersion + return self._plugin_registry.APIVersion.getMajor() if not cura.CuraVersion.CuraSDKVersion: # type: ignore - return self._plugin_registry.APIVersion + return self._plugin_registry.APIVersion.getMajor() return cura.CuraVersion.CuraSDKVersion # type: ignore @pyqtSlot() From 75f2f405344e16d0bc191d40c488cc3cea3888e8 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Thu, 8 Nov 2018 12:04:41 +0100 Subject: [PATCH 2/3] Make API version configuration for Application CURA-5840 --- cura/API/Interface/__init__.py | 4 ---- cura/API/__init__.py | 4 +--- cura/CuraApplication.py | 3 ++- plugins/Toolbox/src/Toolbox.py | 6 +++--- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/cura/API/Interface/__init__.py b/cura/API/Interface/__init__.py index 742254a1a4..cec174bf0a 100644 --- a/cura/API/Interface/__init__.py +++ b/cura/API/Interface/__init__.py @@ -3,7 +3,6 @@ from typing import TYPE_CHECKING -from UM.PluginRegistry import PluginRegistry from cura.API.Interface.Settings import Settings if TYPE_CHECKING: @@ -23,9 +22,6 @@ if TYPE_CHECKING: class Interface: - # For now we use the same API version to be consistent. - VERSION = PluginRegistry.APIVersion - def __init__(self, application: "CuraApplication") -> None: # API methods specific to the settings portion of the UI self.settings = Settings(application) diff --git a/cura/API/__init__.py b/cura/API/__init__.py index ad07452c1a..b3e702263a 100644 --- a/cura/API/__init__.py +++ b/cura/API/__init__.py @@ -4,7 +4,6 @@ from typing import Optional, TYPE_CHECKING from PyQt5.QtCore import QObject, pyqtProperty -from UM.PluginRegistry import PluginRegistry from cura.API.Backups import Backups from cura.API.Interface import Interface from cura.API.Account import Account @@ -22,7 +21,6 @@ if TYPE_CHECKING: class CuraAPI(QObject): # For now we use the same API version to be consistent. - VERSION = PluginRegistry.APIVersion __instance = None # type: "CuraAPI" _application = None # type: CuraApplication @@ -62,4 +60,4 @@ class CuraAPI(QObject): @property def interface(self) -> "Interface": - return self._interface \ No newline at end of file + return self._interface diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index fc9ba1ebf4..7f0e742a9f 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -133,7 +133,7 @@ except ImportError: CuraVersion = "master" # [CodeStyle: Reflecting imported value] CuraBuildType = "" CuraDebugMode = False - CuraSDKVersion = "" + CuraSDKVersion = "5.0.0" class CuraApplication(QtApplication): @@ -162,6 +162,7 @@ class CuraApplication(QtApplication): def __init__(self, *args, **kwargs): super().__init__(name = "cura", version = CuraVersion, + api_version = CuraSDKVersion, buildtype = CuraBuildType, is_debug_mode = CuraDebugMode, tray_icon_name = "cura-icon-32.png", diff --git a/plugins/Toolbox/src/Toolbox.py b/plugins/Toolbox/src/Toolbox.py index 7db4e8bde0..2d9299fb5a 100644 --- a/plugins/Toolbox/src/Toolbox.py +++ b/plugins/Toolbox/src/Toolbox.py @@ -209,11 +209,11 @@ class Toolbox(QObject, Extension): # Get the packages version depending on Cura version settings. def _getSDKVersion(self) -> Union[int, str]: if not hasattr(cura, "CuraVersion"): - return self._plugin_registry.APIVersion.getMajor() + return self._application.getAPIVersion().getMajor() if not hasattr(cura.CuraVersion, "CuraSDKVersion"): # type: ignore - return self._plugin_registry.APIVersion.getMajor() + return self._application.getAPIVersion().getMajor() if not cura.CuraVersion.CuraSDKVersion: # type: ignore - return self._plugin_registry.APIVersion.getMajor() + return self._application.getAPIVersion().getMajor() return cura.CuraVersion.CuraSDKVersion # type: ignore @pyqtSlot() From 7f54cacd0ffb13e07201ac6010457dc62d11c70f Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 9 Nov 2018 14:11:38 +0100 Subject: [PATCH 3/3] Code style Discovered during work on CURA-5840. --- plugins/Toolbox/src/PackagesModel.py | 4 ++-- plugins/Toolbox/src/Toolbox.py | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/plugins/Toolbox/src/PackagesModel.py b/plugins/Toolbox/src/PackagesModel.py index aa5626b7f2..a31facf75a 100644 --- a/plugins/Toolbox/src/PackagesModel.py +++ b/plugins/Toolbox/src/PackagesModel.py @@ -12,7 +12,7 @@ from UM.Qt.ListModel import ListModel from .ConfigsModel import ConfigsModel -## Model that holds cura packages. By setting the filter property the instances held by this model can be changed. +## Model that holds Cura packages. By setting the filter property the instances held by this model can be changed. class PackagesModel(ListModel): def __init__(self, parent = None): super().__init__(parent) @@ -70,7 +70,7 @@ class PackagesModel(ListModel): # Links is a list of dictionaries with "title" and "url". Convert this list into a dict so it's easier # to process. - link_list = package['data']['links'] if 'links' in package['data'] else [] + link_list = package["data"]["links"] if "links" in package["data"] else [] links_dict = {d["title"]: d["url"] for d in link_list} if "author_id" not in package["author"] or "display_name" not in package["author"]: diff --git a/plugins/Toolbox/src/Toolbox.py b/plugins/Toolbox/src/Toolbox.py index 2d9299fb5a..cec7fae6bd 100644 --- a/plugins/Toolbox/src/Toolbox.py +++ b/plugins/Toolbox/src/Toolbox.py @@ -172,18 +172,18 @@ class Toolbox(QObject, Extension): self._cloud_api_version = self._getCloudAPIVersion() self._cloud_api_root = self._getCloudAPIRoot() self._api_url = "{cloud_api_root}/cura-packages/v{cloud_api_version}/cura/v{sdk_version}".format( - cloud_api_root=self._cloud_api_root, - cloud_api_version=self._cloud_api_version, - sdk_version=self._sdk_version + cloud_api_root = self._cloud_api_root, + cloud_api_version = self._cloud_api_version, + sdk_version = self._sdk_version ) self._request_urls = { - "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)), - "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)), - "materials_generic": QUrl("{base_url}/packages?package_type=material&tags=generic".format(base_url=self._api_url)) + "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)), + "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)), + "materials_generic": QUrl("{base_url}/packages?package_type=material&tags=generic".format(base_url = self._api_url)) } # Get the API root for the packages API depending on Cura version settings. @@ -295,7 +295,7 @@ class Toolbox(QObject, Extension): for plugin_id in old_plugin_ids: # Neither the installed packages nor the packages that are scheduled to remove are old plugins if plugin_id not in installed_package_ids and plugin_id not in scheduled_to_remove_package_ids: - Logger.log('i', 'Found a plugin that was installed with the old plugin browser: %s', plugin_id) + 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)