mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
CURA-5442 Compare plugin registry to package manager
This commit is contained in:
parent
0e11a165a3
commit
096f0775a8
2 changed files with 32 additions and 25 deletions
|
@ -134,7 +134,7 @@ class CuraPackageManager(QObject):
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def getAllInstalledPackagesInfo(self) -> dict:
|
def getAllInstalledPackageIDs(self) -> set:
|
||||||
# Add bundled, installed, and to-install packages to the set of installed package IDs
|
# Add bundled, installed, and to-install packages to the set of installed package IDs
|
||||||
all_installed_ids = set()
|
all_installed_ids = set()
|
||||||
|
|
||||||
|
@ -147,6 +147,12 @@ class CuraPackageManager(QObject):
|
||||||
if self._to_install_package_dict.keys():
|
if self._to_install_package_dict.keys():
|
||||||
all_installed_ids = all_installed_ids.union(set(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 <package_type> -> <package_id> -> <package_info>
|
# map of <package_type> -> <package_id> -> <package_info>
|
||||||
installed_packages_dict = {}
|
installed_packages_dict = {}
|
||||||
for package_id in all_installed_ids:
|
for package_id in all_installed_ids:
|
||||||
|
|
|
@ -64,14 +64,17 @@ class Toolbox(QObject, Extension):
|
||||||
]
|
]
|
||||||
self._request_urls = {}
|
self._request_urls = {}
|
||||||
self._to_update = [] # Package_ids that are waiting to be updated
|
self._to_update = [] # Package_ids that are waiting to be updated
|
||||||
|
self._old_plugin_ids = []
|
||||||
|
|
||||||
# Data:
|
# Data:
|
||||||
self._metadata = {
|
self._metadata = {
|
||||||
"authors": [],
|
"authors": [],
|
||||||
"packages": [],
|
"packages": [],
|
||||||
"plugins_showcase": [],
|
"plugins_showcase": [],
|
||||||
|
"plugins_available": [],
|
||||||
"plugins_installed": [],
|
"plugins_installed": [],
|
||||||
"materials_showcase": [],
|
"materials_showcase": [],
|
||||||
|
"materials_available": [],
|
||||||
"materials_installed": []
|
"materials_installed": []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,30 +169,11 @@ class Toolbox(QObject, Extension):
|
||||||
"authors": QUrl("{base_url}/authors".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)),
|
"packages": QUrl("{base_url}/packages".format(base_url=self._api_url)),
|
||||||
"plugins_showcase": QUrl("{base_url}/showcase".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.
|
# Get the API root for the packages API depending on Cura version settings.
|
||||||
def _getCloudAPIRoot(self) -> str:
|
def _getCloudAPIRoot(self) -> str:
|
||||||
if not hasattr(cura, "CuraVersion"):
|
if not hasattr(cura, "CuraVersion"):
|
||||||
|
@ -256,6 +240,17 @@ class Toolbox(QObject, Extension):
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def _updateInstalledModels(self) -> None:
|
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()
|
all_packages = self._package_manager.getAllInstalledPackagesInfo()
|
||||||
if "plugin" in all_packages:
|
if "plugin" in all_packages:
|
||||||
self._metadata["plugins_installed"] = all_packages["plugin"]
|
self._metadata["plugins_installed"] = all_packages["plugin"]
|
||||||
|
@ -346,7 +341,7 @@ class Toolbox(QObject, Extension):
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
@pyqtSlot(str, result = bool)
|
@pyqtSlot(str, result = bool)
|
||||||
def canUpdate(self, package_id: str) -> bool:
|
def canUpdate(self, package_id: str) -> bool:
|
||||||
if self._isOldPlugin(package_id):
|
if self.isOldPlugin(package_id):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
local_package = self._package_manager.getInstalledPackageInfo(package_id)
|
local_package = self._package_manager.getInstalledPackageInfo(package_id)
|
||||||
|
@ -379,7 +374,7 @@ class Toolbox(QObject, Extension):
|
||||||
|
|
||||||
@pyqtSlot(str, result = bool)
|
@pyqtSlot(str, result = bool)
|
||||||
def isInstalled(self, package_id: str) -> 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)
|
@pyqtSlot(str, result = bool)
|
||||||
def isEnabled(self, package_id: str) -> bool:
|
def isEnabled(self, package_id: str) -> bool:
|
||||||
|
@ -387,6 +382,12 @@ class Toolbox(QObject, Extension):
|
||||||
return True
|
return True
|
||||||
return False
|
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:
|
def loadingComplete(self) -> bool:
|
||||||
populated = 0
|
populated = 0
|
||||||
for list in self._metadata.items():
|
for list in self._metadata.items():
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue