Digital Library plugin needs to be backwards compatible.

Message-types are a new parameter to Messages, so they can't be used in SDK/API versions smaller than 7.7.0.

CURA-8473
This commit is contained in:
Remco Burema 2021-08-11 12:09:50 +02:00
parent 8b2904ee3b
commit 5d7804deae
No known key found for this signature in database
GPG key ID: 215C49431D43F98C
3 changed files with 41 additions and 24 deletions

View file

@ -23,6 +23,7 @@ from UM.TaskManagement.HttpRequestManager import HttpRequestManager
from cura.API import Account
from cura.CuraApplication import CuraApplication
from cura.UltimakerCloud.UltimakerCloudScope import UltimakerCloudScope
from .BackwardsCompatibleMessage import getBackwardsCompatibleMessage
from .DFFileExportAndUploadManager import DFFileExportAndUploadManager
from .DigitalFactoryApiClient import DigitalFactoryApiClient
from .DigitalFactoryFileModel import DigitalFactoryFileModel
@ -527,11 +528,11 @@ class DigitalFactoryController(QObject):
except IOError as ex:
Logger.logException("e", "Can't write Digital Library file {0}/{1} download to temp-directory {2}.",
ex, project_name, file_name, temp_dir)
Message(
getBackwardsCompatibleMessage(
text = "Failed to write to temporary file for '{}'.".format(file_name),
title = "File-system error",
lifetime = 10,
message_type=Message.MessageType.ERROR
message_type_str="ERROR"
).show()
return
@ -542,11 +543,11 @@ class DigitalFactoryController(QObject):
f = file_name) -> None:
progress_message.hide()
Logger.error("An error {0} {1} occurred while downloading {2}/{3}".format(str(error), str(reply), p, f))
Message(
getBackwardsCompatibleMessage(
text = "Failed Digital Library download for '{}'.".format(f),
title = "Network error {}".format(error),
lifetime = 10,
message_type=Message.MessageType.ERROR
message_type_str="ERROR"
).show()
download_manager = HttpRequestManager.getInstance()
@ -591,10 +592,10 @@ class DigitalFactoryController(QObject):
if filename == "":
Logger.log("w", "The file name cannot be empty.")
Message(text = "Cannot upload file with an empty name to the Digital Library",
getBackwardsCompatibleMessage(text = "Cannot upload file with an empty name to the Digital Library",
title = "Empty file name provided",
lifetime = 0,
message_type = Message.MessageType.ERROR).show()
message_type_str = "ERROR").show()
return
self._saveFileToSelectedProjectHelper(filename, formats)