mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-11 16:57:51 -06:00
Process review comments
CURA-7099
This commit is contained in:
parent
d4eb463f2d
commit
8c250cfbbc
2 changed files with 11 additions and 13 deletions
|
@ -474,7 +474,7 @@ class CuraApplication(QtApplication):
|
|||
"CuraEngineBackend", #Cura is useless without this one since you can't slice.
|
||||
"FileLogger", #You want to be able to read the log if something goes wrong.
|
||||
"XmlMaterialProfile", #Cura crashes without this one.
|
||||
"Toolbox", #This contains the interface to enable/disable plug-ins and the Cloud functionality.
|
||||
"Toolbox", #This contains the interface to enable/disable plug-ins, so if you disable it you can't enable it back.
|
||||
"PrepareStage", #Cura is useless without this one since you can't load models.
|
||||
"PreviewStage", #This shows the list of the plugin views that are installed in Cura.
|
||||
"MonitorStage", #Major part of Cura's functionality.
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
from UM.Logger import Logger
|
||||
from UM.TaskManagement.HttpRequestManager import HttpRequestManager
|
||||
from cura.API import Account
|
||||
from cura.CuraApplication import CuraApplication
|
||||
from ..CloudApiModel import CloudApiModel
|
||||
from ..UltimakerCloudScope import UltimakerCloudScope
|
||||
|
@ -25,29 +24,28 @@ class CloudPackageManager:
|
|||
|
||||
def __init__(self, app: CuraApplication) -> None:
|
||||
if self.__instance is not None:
|
||||
raise Exception("This is a Singleton. use getInstance()")
|
||||
raise RuntimeError("This is a Singleton. use getInstance()")
|
||||
|
||||
self._request_manager = app.getHttpRequestManager() # type: HttpRequestManager
|
||||
self.account = app.getCuraAPI().account # type: Account
|
||||
self._scope = UltimakerCloudScope(app) # type: UltimakerCloudScope
|
||||
|
||||
app.getPackageManager().packageInstalled.connect(self._onPackageInstalled)
|
||||
|
||||
def unsubscribe(self, package_id: str) -> None:
|
||||
url = CloudApiModel.userPackageUrl(package_id)
|
||||
self._request_manager.delete(url=url, scope=self._scope)
|
||||
HttpRequestManager.getInstance().delete(url=url, scope=self._scope)
|
||||
|
||||
def subscribe(self, package_id: str) -> None:
|
||||
def _subscribe(self, package_id: str) -> None:
|
||||
"""You probably don't want to use this directly. All installed packages will be automatically subscribed."""
|
||||
|
||||
Logger.debug("Subscribing to {}", package_id)
|
||||
data = "{\"data\": {\"package_id\": \"%s\", \"sdk_version\": \"%s\"}}" % (package_id, CloudApiModel.sdk_version)
|
||||
self._request_manager.put(url=CloudApiModel.api_url_user_packages,
|
||||
HttpRequestManager.getInstance().put(
|
||||
url=CloudApiModel.api_url_user_packages,
|
||||
data=data.encode(),
|
||||
scope=self._scope
|
||||
)
|
||||
|
||||
def _onPackageInstalled(self, package_id: str):
|
||||
if self.account.isLoggedIn:
|
||||
if CuraApplication.getInstance().getCuraAPI().account.isLoggedIn:
|
||||
# We might already be subscribed, but checking would take one extra request. Instead, simply subscribe
|
||||
self.subscribe(package_id)
|
||||
self._subscribe(package_id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue