diff options
author | Nino van Hooff <ninovanhooff@gmail.com> | 2020-01-10 16:20:58 +0300 |
---|---|---|
committer | Nino van Hooff <ninovanhooff@gmail.com> | 2020-01-10 16:20:58 +0300 |
commit | 35695e5ab65afb0feac1d9888d824d656e5af52a (patch) | |
tree | 4e2cce3fc3dc7811d64c1f5a244b81820b286887 /plugins/Toolbox/src/CloudSync/SyncOrchestrator.py | |
parent | 1cf3cd8228c9eb10e023a3f10cbdbabbd52a7d5e (diff) |
Install and cloud-subscribe a package when after agreeing to the license
CURA-6983
Diffstat (limited to 'plugins/Toolbox/src/CloudSync/SyncOrchestrator.py')
-rw-r--r-- | plugins/Toolbox/src/CloudSync/SyncOrchestrator.py | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/plugins/Toolbox/src/CloudSync/SyncOrchestrator.py b/plugins/Toolbox/src/CloudSync/SyncOrchestrator.py index 952f3eeb54..507de45f55 100644 --- a/plugins/Toolbox/src/CloudSync/SyncOrchestrator.py +++ b/plugins/Toolbox/src/CloudSync/SyncOrchestrator.py @@ -1,10 +1,13 @@ -from typing import List, Dict +import os +from typing import List, Dict, Any from UM.Extension import Extension from UM.Logger import Logger +from UM.PackageManager import PackageManager from UM.PluginRegistry import PluginRegistry from cura.CuraApplication import CuraApplication from plugins.Toolbox.src.CloudSync.CloudPackageChecker import CloudPackageChecker +from plugins.Toolbox.src.CloudSync.CloudPackageManager import CloudPackageManager from plugins.Toolbox.src.CloudSync.DiscrepanciesPresenter import DiscrepanciesPresenter from plugins.Toolbox.src.CloudSync.DownloadPresenter import DownloadPresenter from plugins.Toolbox.src.CloudSync.LicensePresenter import LicensePresenter @@ -32,6 +35,9 @@ class SyncOrchestrator(Extension): # getPluginId() will return the same value for The toolbox extension and this one self._name = "SyncOrchestrator" + self._package_manager = app.getPackageManager() + self._cloud_package_manager = CloudPackageManager(app) + self._checker = CloudPackageChecker(app) # type: CloudPackageChecker self._checker.discrepancies.connect(self._onDiscrepancies) @@ -61,7 +67,24 @@ class SyncOrchestrator(Extension): self._licensePresenter.present(plugin_path, success_items) # Called when user has accepted / declined all licenses for the downloaded packages - def _onLicenseAnswers(self, answers: Dict[str, bool]): + def _onLicenseAnswers(self, answers: [Dict[str, Any]]): Logger.debug("Got license answers: {}", answers) + for item in answers: + if item["accepted"]: + # install and subscribe packages + if not self._package_manager.installPackage(item["package_path"]): + Logger.error("could not install {}".format(item["package_id"])) + continue + self._cloud_package_manager.subscribe(item["package_id"]) + else: + # todo unsubscribe declined packages + pass + + # delete temp file + os.remove(item["package_path"]) + + + + |