mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 23:46:22 -06:00
Added uninstall functionality
Get it in a sharable state Contributes to: CURA-8587
This commit is contained in:
parent
3b3d986058
commit
00acfe9d72
2 changed files with 26 additions and 3 deletions
|
@ -69,7 +69,6 @@ class CuraPackageManager(PackageManager):
|
||||||
def iterateAllLocalPackages(self) -> Generator[Dict[str, Any], None, None]:
|
def iterateAllLocalPackages(self) -> Generator[Dict[str, Any], None, None]:
|
||||||
""" A generator which returns an unordered list of all the PackageModels"""
|
""" A generator which returns an unordered list of all the PackageModels"""
|
||||||
|
|
||||||
# Get all the installed packages, add a section_title depending on package_type and user installed
|
|
||||||
for packages in self.getAllInstalledPackagesInfo().values():
|
for packages in self.getAllInstalledPackagesInfo().values():
|
||||||
for package_info in packages:
|
for package_info in packages:
|
||||||
yield package_info
|
yield package_info
|
||||||
|
|
|
@ -12,6 +12,8 @@ from UM.TaskManagement.HttpRequestManager import HttpRequestData , HttpRequestMa
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
|
|
||||||
from cura.CuraApplication import CuraApplication
|
from cura.CuraApplication import CuraApplication
|
||||||
|
from cura.API.Account import Account
|
||||||
|
from cura 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
|
||||||
|
@ -31,7 +33,8 @@ 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 = CuraApplication.getInstance().getPackageManager()
|
self._manager: CuraPackageManager = CuraApplication.getInstance().getPackageManager()
|
||||||
|
self._account: Account = CuraApplication.getInstance().getCuraAPI().account
|
||||||
self._error_message = ""
|
self._error_message = ""
|
||||||
self.addRoleName(self.PackageRole, "package")
|
self.addRoleName(self.PackageRole, "package")
|
||||||
self._is_loading = False
|
self._is_loading = False
|
||||||
|
@ -126,7 +129,7 @@ class PackageList(ListModel):
|
||||||
def downloadFinished(reply: "QNetworkReply") -> None:
|
def downloadFinished(reply: "QNetworkReply") -> None:
|
||||||
self._downloadFinished(package_id, reply, update)
|
self._downloadFinished(package_id, reply, update)
|
||||||
|
|
||||||
HttpRequestManager.getInstance().get(
|
self._ongoing_request = HttpRequestManager.getInstance().get(
|
||||||
url,
|
url,
|
||||||
scope = self._scope,
|
scope = self._scope,
|
||||||
callback = downloadFinished
|
callback = downloadFinished
|
||||||
|
@ -165,13 +168,34 @@ class PackageList(ListModel):
|
||||||
package.setIsUpdating(False)
|
package.setIsUpdating(False)
|
||||||
else:
|
else:
|
||||||
package.setIsInstalling(False)
|
package.setIsInstalling(False)
|
||||||
|
#self._subscribe(package_id)
|
||||||
|
|
||||||
|
def _subscribe(self, package_id: str) -> None:
|
||||||
|
if self._account.isLoggedIn:
|
||||||
|
Logger.debug(f"Subscribing the user for package: {package_id}")
|
||||||
|
self._ongoing_request = HttpRequestManager.getInstance().put(
|
||||||
|
url = "",
|
||||||
|
data = {},
|
||||||
|
scope = self._scope
|
||||||
|
)
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
def uninstallPackage(self, package_id):
|
def uninstallPackage(self, package_id):
|
||||||
Logger.debug(f"Uninstalling {package_id}")
|
Logger.debug(f"Uninstalling {package_id}")
|
||||||
|
package = self._getPackageModel(package_id)
|
||||||
|
self._manager.removePackage(package_id)
|
||||||
|
package.setIsInstalling(False)
|
||||||
|
package.setManageInstallState(False)
|
||||||
|
#self._unsunscribe(package_id)
|
||||||
|
|
||||||
|
def _unsunscribe(self, package_id: str) -> None:
|
||||||
|
if self._account.isLoggedIn:
|
||||||
|
Logger.debug(f"Unsubscribing the user for package: {package_id}")
|
||||||
|
self._ongoing_request = HttpRequestManager.getInstance().delete(url = "", scope = self._scope)
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
def updatePackage(self, package_id):
|
def updatePackage(self, package_id):
|
||||||
|
self._manager.removePackage(package_id, force_add = True)
|
||||||
package = self._getPackageModel(package_id)
|
package = self._getPackageModel(package_id)
|
||||||
url = package.download_url
|
url = package.download_url
|
||||||
Logger.debug(f"Trying to download and update {package_id} from {url}")
|
Logger.debug(f"Trying to download and update {package_id} from {url}")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue