Merge branch 'CURA-8587_disable_update_install_and_uninstall' into cura-8587_disable_update_install_and_update/licence_agreement

This commit is contained in:
casper 2021-12-06 17:23:31 +01:00
commit 324b456cbd
3 changed files with 12 additions and 7 deletions

View file

@ -1,7 +1,7 @@
# Copyright (c) 2018 Ultimaker B.V. # Copyright (c) 2018 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher. # Cura is released under the terms of the LGPLv3 or higher.
from typing import Any, Dict, List, Tuple, TYPE_CHECKING, Optional, Generator from typing import Any, cast, Dict, List, Tuple, TYPE_CHECKING, Optional, Generator
from cura.CuraApplication import CuraApplication #To find some resource types. from cura.CuraApplication import CuraApplication #To find some resource types.
from cura.Settings.GlobalStack import GlobalStack from cura.Settings.GlobalStack import GlobalStack
@ -30,7 +30,9 @@ class CuraPackageManager(PackageManager):
"""locally installed packages, lazy execution""" """locally installed packages, lazy execution"""
if self._local_packages is None: if self._local_packages is None:
self._updateLocalPackages() self._updateLocalPackages()
return self._local_packages # _updateLocalPackages always results in a list of packages, not None.
# It's guaranteed to be a list now.
return cast(List[Dict[str, Any]], self._local_packages)
def initialize(self) -> None: def initialize(self) -> None:
self._installation_dirs_dict["materials"] = Resources.getStoragePath(CuraApplication.ResourceTypes.MaterialInstanceContainer) self._installation_dirs_dict["materials"] = Resources.getStoragePath(CuraApplication.ResourceTypes.MaterialInstanceContainer)

View file

@ -5,7 +5,7 @@ import json
import os.path import os.path
from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, Qt from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, Qt
from typing import Dict, Optional, Set, TYPE_CHECKING from typing import cast, Dict, Optional, Set, TYPE_CHECKING
from UM.i18n import i18nCatalog from UM.i18n import i18nCatalog
from UM.Qt.ListModel import ListModel from UM.Qt.ListModel import ListModel
@ -15,7 +15,7 @@ from UM.Logger import Logger
from UM import PluginRegistry from UM import PluginRegistry
from cura.CuraApplication import CuraApplication from cura.CuraApplication import CuraApplication
from cura import CuraPackageManager from cura.CuraPackageManager import CuraPackageManager
from cura.UltimakerCloud.UltimakerCloudScope import UltimakerCloudScope # To make requests to the Ultimaker API with correct authorization. from cura.UltimakerCloud.UltimakerCloudScope import UltimakerCloudScope # To make requests to the Ultimaker API with correct authorization.
from .PackageModel import PackageModel from .PackageModel import PackageModel
@ -24,6 +24,7 @@ from .LicenseModel import LicenseModel
if TYPE_CHECKING: if TYPE_CHECKING:
from PyQt5.QtCore import QObject from PyQt5.QtCore import QObject
from PyQt5.QtNetwork import QNetworkReply
catalog = i18nCatalog("cura") catalog = i18nCatalog("cura")
@ -37,7 +38,7 @@ class PackageList(ListModel):
def __init__(self, parent: Optional["QObject"] = None) -> None: def __init__(self, parent: Optional["QObject"] = None) -> None:
super().__init__(parent) super().__init__(parent)
self._manager: CuraPackageManager = CuraApplication.getInstance().getPackageManager() self._manager: CuraPackageManager = cast(CuraPackageManager, CuraApplication.getInstance().getPackageManager())
self._plugin_registry: PluginRegistry = CuraApplication.getInstance().getPluginRegistry() self._plugin_registry: PluginRegistry = CuraApplication.getInstance().getPluginRegistry()
self._account = CuraApplication.getInstance().getCuraAPI().account self._account = CuraApplication.getInstance().getCuraAPI().account
self._error_message = "" self._error_message = ""

View file

@ -71,11 +71,13 @@ class PackageModel(QObject):
self.sdk_version = package_data.get("sdk_version_semver", "") self.sdk_version = package_data.get("sdk_version_semver", "")
# Note that there's a lot more info in the package_data than just these specified here. # Note that there's a lot more info in the package_data than just these specified here.
def __eq__(self, other: Union[str, "PackageModel"]): def __eq__(self, other: object):
if isinstance(other, PackageModel): if isinstance(other, PackageModel):
return other == self return other == self
else: elif isinstance(other, str):
return other == self._package_id return other == self._package_id
else:
return False
def __repr__(self): def __repr__(self):
return f"<{self._package_id} : {self._package_version} : {self._section_title}>" return f"<{self._package_id} : {self._package_version} : {self._section_title}>"