Merge branch 'master' of github.com:Ultimaker/Cura into CURA-7162/replace_robot_with_placeholder

This commit is contained in:
Dimitriovski 2020-02-27 11:20:38 +01:00
commit 24e2fc89e5
No known key found for this signature in database
GPG key ID: 4E62757E2B0D304D
52 changed files with 4859 additions and 2121 deletions

View file

@ -1,3 +1,6 @@
# Copyright (c) 2020 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
import json
from typing import Optional
@ -23,6 +26,7 @@ class CloudPackageChecker(QObject):
self._application = application # type: CuraApplication
self._scope = UltimakerCloudScope(application)
self._model = SubscribedPackagesModel()
self._message = None # type: Optional[Message]
self._application.initializationFinished.connect(self._onAppInitialized)
self._i18n_catalog = i18nCatalog("cura")
@ -33,13 +37,16 @@ class CloudPackageChecker(QObject):
def _onAppInitialized(self) -> None:
self._package_manager = self._application.getPackageManager()
# initial check
self._fetchUserSubscribedPackages()
self._onLoginStateChanged()
# check again whenever the login state changes
self._application.getCuraAPI().account.loginStateChanged.connect(self._fetchUserSubscribedPackages)
self._application.getCuraAPI().account.loginStateChanged.connect(self._onLoginStateChanged)
def _fetchUserSubscribedPackages(self) -> None:
def _onLoginStateChanged(self) -> None:
if self._application.getCuraAPI().account.isLoggedIn:
self._getUserSubscribedPackages()
elif self._message is not None:
self._message.hide()
self._message = None
def _getUserSubscribedPackages(self) -> None:
Logger.debug("Requesting subscribed packages metadata from server.")
@ -90,16 +97,17 @@ class CloudPackageChecker(QObject):
Logger.log("d", "Discrepancy found between Cloud subscribed packages and Cura installed packages")
sync_message = Message(self._i18n_catalog.i18nc(
"@info:generic",
"\nDo you want to sync material and software packages with your account?"),
title=self._i18n_catalog.i18nc("@info:title", "Changes detected from your Ultimaker account", ),
lifetime=0)
"Do you want to sync material and software packages with your account?"),
title = self._i18n_catalog.i18nc("@info:title", "Changes detected from your Ultimaker account", ),
lifetime = 0)
sync_message.addAction("sync",
name=self._i18n_catalog.i18nc("@action:button", "Sync"),
icon="",
description="Sync your Cloud subscribed packages to your local environment.",
button_align=Message.ActionButtonAlignment.ALIGN_RIGHT)
name = self._i18n_catalog.i18nc("@action:button", "Sync"),
icon = "",
description = "Sync your Cloud subscribed packages to your local environment.",
button_align = Message.ActionButtonAlignment.ALIGN_RIGHT)
sync_message.actionTriggered.connect(self._onSyncButtonClicked)
sync_message.show()
self._message = sync_message
def _onSyncButtonClicked(self, sync_message: Message, sync_message_action: str) -> None:
sync_message.hide()

View file

@ -1,3 +1,6 @@
# Copyright (c) 2020 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
import tempfile
from typing import Dict, List, Any
@ -81,11 +84,9 @@ class DownloadPresenter:
return DownloadPresenter(self._app)
def _createProgressMessage(self) -> Message:
return Message(i18n_catalog.i18nc(
"@info:generic",
"\nSyncing..."),
return Message(i18n_catalog.i18nc("@info:generic", "Syncing..."),
lifetime = 0,
use_inactivity_timer=False,
use_inactivity_timer = False,
progress = 0.0,
title = i18n_catalog.i18nc("@info:title", "Changes detected from your Ultimaker account", ))
@ -93,7 +94,7 @@ class DownloadPresenter:
self._progress[package_id]["received"] = self._progress[package_id]["total"]
try:
with tempfile.NamedTemporaryFile(mode ="wb+", suffix =".curapackage", delete = False) as temp_file:
with tempfile.NamedTemporaryFile(mode = "wb+", suffix = ".curapackage", delete = False) as temp_file:
bytes_read = reply.read(self.DISK_WRITE_BUFFER_SIZE)
while bytes_read:
temp_file.write(bytes_read)

View file

@ -67,17 +67,22 @@ class PackagesModel(ListModel):
links_dict = {}
if "data" in package:
# Links is a list of dictionaries with "title" and "url". Convert this list into a dict so it's easier
# to process.
link_list = package["data"]["links"] if "links" in package["data"] else []
links_dict = {d["title"]: d["url"] for d in link_list}
# This code never gets executed because the API response does not contain "supported_configs" in it
# It is so because 2y ago when this was created - it did contain it. But it was a prototype only
# and never got to production. As agreed with the team, it'll stay here for now, in case we decide to rework and use it
# The response payload has been changed. Please see:
# https://github.com/Ultimaker/Cura/compare/CURA-7072-temp?expand=1
if "supported_configs" in package["data"]:
if len(package["data"]["supported_configs"]) > 0:
has_configs = True
configs_model = ConfigsModel()
configs_model.setConfigs(package["data"]["supported_configs"])
# Links is a list of dictionaries with "title" and "url". Convert this list into a dict so it's easier
# to process.
link_list = package["data"]["links"] if "links" in package["data"] else []
links_dict = {d["title"]: d["url"] for d in link_list}
if "author_id" not in package["author"] or "display_name" not in package["author"]:
package["author"]["author_id"] = ""
package["author"]["display_name"] = ""