Refactor: rename CloudPackageManager to CloudApiClient

This commit is contained in:
Nino van Hooff 2020-02-14 16:33:24 +01:00
parent 089561dd22
commit 507459660e
2 changed files with 8 additions and 8 deletions

View file

@ -5,13 +5,13 @@ from ..CloudApiModel import CloudApiModel
from ..UltimakerCloudScope import UltimakerCloudScope from ..UltimakerCloudScope import UltimakerCloudScope
class CloudPackageManager: class CloudApiClient:
"""Manages Cloud subscriptions """Manages Cloud subscriptions
When a package is added to a user's account, the user is 'subscribed' to that package. When a package is added to a user's account, the user is 'subscribed' to that package.
Whenever the user logs in on another instance of Cura, these subscriptions can be used to sync the user's plugins Whenever the user logs in on another instance of Cura, these subscriptions can be used to sync the user's plugins
Singleton: use CloudPackageManager.getInstance() instead of CloudPackageManager() Singleton: use CloudApiClient.getInstance() instead of CloudApiClient()
""" """
__instance = None __instance = None
@ -19,7 +19,7 @@ class CloudPackageManager:
@classmethod @classmethod
def getInstance(cls, app: CuraApplication): def getInstance(cls, app: CuraApplication):
if not cls.__instance: if not cls.__instance:
cls.__instance = CloudPackageManager(app) cls.__instance = CloudApiClient(app)
return cls.__instance return cls.__instance
def __init__(self, app: CuraApplication) -> None: def __init__(self, app: CuraApplication) -> None:

View file

@ -8,7 +8,7 @@ from UM.Message import Message
from UM.PluginRegistry import PluginRegistry from UM.PluginRegistry import PluginRegistry
from cura.CuraApplication import CuraApplication from cura.CuraApplication import CuraApplication
from .CloudPackageChecker import CloudPackageChecker from .CloudPackageChecker import CloudPackageChecker
from .CloudPackageManager import CloudPackageManager from .CloudApiClient import CloudApiClient
from .DiscrepanciesPresenter import DiscrepanciesPresenter from .DiscrepanciesPresenter import DiscrepanciesPresenter
from .DownloadPresenter import DownloadPresenter from .DownloadPresenter import DownloadPresenter
from .LicensePresenter import LicensePresenter from .LicensePresenter import LicensePresenter
@ -26,7 +26,7 @@ from .SubscribedPackagesModel import SubscribedPackagesModel
# - The DownloadPresenter shows a download progress dialog. It emits A tuple of succeeded and failed downloads # - The DownloadPresenter shows a download progress dialog. It emits A tuple of succeeded and failed downloads
# - The LicensePresenter extracts licenses from the downloaded packages and presents a license for each package to # - The LicensePresenter extracts licenses from the downloaded packages and presents a license for each package to
# be installed. It emits the `licenseAnswers` signal for accept or declines # be installed. It emits the `licenseAnswers` signal for accept or declines
# - The CloudPackageManager removes the declined packages from the account # - The CloudApiClient removes the declined packages from the account
# - The SyncOrchestrator uses PackageManager to install the downloaded packages and delete temp files. # - The SyncOrchestrator uses PackageManager to install the downloaded packages and delete temp files.
# - The RestartApplicationPresenter notifies the user that a restart is required for changes to take effect # - The RestartApplicationPresenter notifies the user that a restart is required for changes to take effect
class SyncOrchestrator(Extension): class SyncOrchestrator(Extension):
@ -38,8 +38,8 @@ class SyncOrchestrator(Extension):
self._name = "SyncOrchestrator" self._name = "SyncOrchestrator"
self._package_manager = app.getPackageManager() self._package_manager = app.getPackageManager()
# Keep a reference to the CloudPackageManager. it watches for installed packages and subscribes to them # Keep a reference to the CloudApiClient. it watches for installed packages and subscribes to them
self._cloud_package_manager = CloudPackageManager.getInstance(app) # type: CloudPackageManager self._cloud_api = CloudApiClient.getInstance(app) # type: CloudApiClient
self._checker = CloudPackageChecker(app) # type: CloudPackageChecker self._checker = CloudPackageChecker(app) # type: CloudPackageChecker
self._checker.discrepancies.connect(self._onDiscrepancies) self._checker.discrepancies.connect(self._onDiscrepancies)
@ -87,7 +87,7 @@ class SyncOrchestrator(Extension):
continue continue
has_changes = True has_changes = True
else: else:
self._cloud_package_manager.unsubscribe(item["package_id"]) self._cloud_api.unsubscribe(item["package_id"])
# delete temp file # delete temp file
os.remove(item["package_path"]) os.remove(item["package_path"])