mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
For makerbot files upload in cloud
CURA-11138
This commit is contained in:
parent
a247e81bb3
commit
3bfc0afc93
4 changed files with 41 additions and 12 deletions
|
@ -213,7 +213,8 @@ Item
|
||||||
valueRole: "value"
|
valueRole: "value"
|
||||||
|
|
||||||
model: [
|
model: [
|
||||||
{ text: catalog.i18nc("@option", "Save Cura project and print file"), key: "3mf_ufp", value: ["3mf", "ufp"] },
|
{ text: catalog.i18nc("@option", "Save Cura project and .ufp print file"), key: "3mf_ufp", value: ["3mf", "ufp"] },
|
||||||
|
{ text: catalog.i18nc("@option", "Save Cura project and .makerbot print file"), key: "3mf_makerbot", value: ["3mf", "makerbot"] },
|
||||||
{ text: catalog.i18nc("@option", "Save Cura project"), key: "3mf", value: ["3mf"] },
|
{ text: catalog.i18nc("@option", "Save Cura project"), key: "3mf", value: ["3mf"] },
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ from .ExportFileJob import ExportFileJob
|
||||||
class DFFileExportAndUploadManager:
|
class DFFileExportAndUploadManager:
|
||||||
"""
|
"""
|
||||||
Class responsible for exporting the scene and uploading the exported data to the Digital Factory Library. Since 3mf
|
Class responsible for exporting the scene and uploading the exported data to the Digital Factory Library. Since 3mf
|
||||||
and UFP files may need to be uploaded at the same time, this class keeps a single progress and success message for
|
and (UFP or makerbot) files may need to be uploaded at the same time, this class keeps a single progress and success message for
|
||||||
both files and updates those messages according to the progress of both the file job uploads.
|
both files and updates those messages according to the progress of both the file job uploads.
|
||||||
"""
|
"""
|
||||||
def __init__(self, file_handlers: Dict[str, FileHandler],
|
def __init__(self, file_handlers: Dict[str, FileHandler],
|
||||||
|
@ -118,7 +118,7 @@ class DFFileExportAndUploadManager:
|
||||||
library_project_id = self._library_project_id,
|
library_project_id = self._library_project_id,
|
||||||
source_file_id = self._source_file_id
|
source_file_id = self._source_file_id
|
||||||
)
|
)
|
||||||
self._api.requestUploadUFP(request, on_finished = self._uploadFileData, on_error = self._onRequestUploadPrintFileFailed)
|
self._api.requestUploadMeshFile(request, on_finished = self._uploadFileData, on_error = self._onRequestUploadPrintFileFailed)
|
||||||
|
|
||||||
def _uploadFileData(self, file_upload_response: Union[DFLibraryFileUploadResponse, DFPrintJobUploadResponse]) -> None:
|
def _uploadFileData(self, file_upload_response: Union[DFLibraryFileUploadResponse, DFPrintJobUploadResponse]) -> None:
|
||||||
"""Uploads the exported file data after the file or print job upload has been registered at the Digital Factory
|
"""Uploads the exported file data after the file or print job upload has been registered at the Digital Factory
|
||||||
|
@ -279,22 +279,25 @@ class DFFileExportAndUploadManager:
|
||||||
This means that something went wrong with the initial request to create a "file" entry in the digital library.
|
This means that something went wrong with the initial request to create a "file" entry in the digital library.
|
||||||
"""
|
"""
|
||||||
reply_string = bytes(reply.readAll()).decode()
|
reply_string = bytes(reply.readAll()).decode()
|
||||||
filename_ufp = self._file_name + ".ufp"
|
if "ufp" in self._formats:
|
||||||
Logger.log("d", "An error occurred while uploading the print job file '{}' to the Digital Library project '{}': {}".format(filename_ufp, self._library_project_id, reply_string))
|
filename_meshfile = self._file_name + ".ufp"
|
||||||
|
elif "makerbot" in self._formats:
|
||||||
|
filename_meshfile = self._file_name + ".makerbot"
|
||||||
|
Logger.log("d", "An error occurred while uploading the print job file '{}' to the Digital Library project '{}': {}".format(filename_meshfile, self._library_project_id, reply_string))
|
||||||
with self._message_lock:
|
with self._message_lock:
|
||||||
# Set the progress to 100% when the upload job fails, to avoid having the progress message stuck
|
# Set the progress to 100% when the upload job fails, to avoid having the progress message stuck
|
||||||
self._file_upload_job_metadata[filename_ufp]["upload_status"] = "failed"
|
self._file_upload_job_metadata[filename_meshfile]["upload_status"] = "failed"
|
||||||
self._file_upload_job_metadata[filename_ufp]["upload_progress"] = 100
|
self._file_upload_job_metadata[filename_meshfile]["upload_progress"] = 100
|
||||||
|
|
||||||
human_readable_error = self.extractErrorTitle(reply_string)
|
human_readable_error = self.extractErrorTitle(reply_string)
|
||||||
self._file_upload_job_metadata[filename_ufp]["file_upload_failed_message"] = getBackwardsCompatibleMessage(
|
self._file_upload_job_metadata[filename_meshfile]["file_upload_failed_message"] = getBackwardsCompatibleMessage(
|
||||||
title = "File upload error",
|
title = "File upload error",
|
||||||
text = "Failed to upload the file '{}' to '{}'. {}".format(filename_ufp, self._library_project_name, human_readable_error),
|
text = "Failed to upload the file '{}' to '{}'. {}".format(filename_meshfile, self._library_project_name, human_readable_error),
|
||||||
message_type_str = "ERROR",
|
message_type_str = "ERROR",
|
||||||
lifetime = 30
|
lifetime = 30
|
||||||
)
|
)
|
||||||
self._on_upload_error()
|
self._on_upload_error()
|
||||||
self._onFileUploadFinished(filename_ufp)
|
self._onFileUploadFinished(filename_meshfile)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def extractErrorTitle(reply_body: Optional[str]) -> str:
|
def extractErrorTitle(reply_body: Optional[str]) -> str:
|
||||||
|
@ -407,4 +410,28 @@ class DFFileExportAndUploadManager:
|
||||||
job_ufp = ExportFileJob(self._file_handlers["ufp"], self._nodes, self._file_name, "ufp")
|
job_ufp = ExportFileJob(self._file_handlers["ufp"], self._nodes, self._file_name, "ufp")
|
||||||
job_ufp.finished.connect(self._onPrintFileExported)
|
job_ufp.finished.connect(self._onPrintFileExported)
|
||||||
self._upload_jobs.append(job_ufp)
|
self._upload_jobs.append(job_ufp)
|
||||||
|
|
||||||
|
if "makerbot" in self._formats and "makerbot" in self._file_handlers and self._file_handlers["makerbot"]:
|
||||||
|
filename_makerbot = self._file_name + ".makerbot"
|
||||||
|
metadata[filename_makerbot] = {
|
||||||
|
"export_job_output" : None,
|
||||||
|
"upload_progress" : -1,
|
||||||
|
"upload_status" : "",
|
||||||
|
"file_upload_response": None,
|
||||||
|
"file_upload_success_message": getBackwardsCompatibleMessage(
|
||||||
|
text = "'{}' was uploaded to '{}'.".format(filename_makerbot, self._library_project_name),
|
||||||
|
title = "Upload successful",
|
||||||
|
message_type_str = "POSITIVE",
|
||||||
|
lifetime = 30,
|
||||||
|
),
|
||||||
|
"file_upload_failed_message": getBackwardsCompatibleMessage(
|
||||||
|
text = "Failed to upload the file '{}' to '{}'.".format(filename_makerbot, self._library_project_name),
|
||||||
|
title = "File upload error",
|
||||||
|
message_type_str = "ERROR",
|
||||||
|
lifetime = 30
|
||||||
|
)
|
||||||
|
}
|
||||||
|
job_makerbot = ExportFileJob(self._file_handlers["makerbot"], self._nodes, self._file_name, "makerbot")
|
||||||
|
job_makerbot.finished.connect(self._onPrintFileExported)
|
||||||
|
self._upload_jobs.append(job_makerbot)
|
||||||
return metadata
|
return metadata
|
||||||
|
|
|
@ -313,7 +313,7 @@ class DigitalFactoryApiClient:
|
||||||
error_callback = on_error,
|
error_callback = on_error,
|
||||||
timeout = self.DEFAULT_REQUEST_TIMEOUT)
|
timeout = self.DEFAULT_REQUEST_TIMEOUT)
|
||||||
|
|
||||||
def requestUploadUFP(self, request: DFPrintJobUploadRequest,
|
def requestUploadMeshFile(self, request: DFPrintJobUploadRequest,
|
||||||
on_finished: Callable[[DFPrintJobUploadResponse], Any],
|
on_finished: Callable[[DFPrintJobUploadResponse], Any],
|
||||||
on_error: Optional[Callable[["QNetworkReply", "QNetworkReply.NetworkError"], None]] = None) -> None:
|
on_error: Optional[Callable[["QNetworkReply", "QNetworkReply.NetworkError"], None]] = None) -> None:
|
||||||
"""Requests the Digital Factory to register the upload of a file in a library project.
|
"""Requests the Digital Factory to register the upload of a file in a library project.
|
||||||
|
|
|
@ -92,7 +92,8 @@ class DigitalFactoryOutputDevice(ProjectOutputDevice):
|
||||||
if not self._controller.file_handlers:
|
if not self._controller.file_handlers:
|
||||||
self._controller.file_handlers = {
|
self._controller.file_handlers = {
|
||||||
"3mf": CuraApplication.getInstance().getWorkspaceFileHandler(),
|
"3mf": CuraApplication.getInstance().getWorkspaceFileHandler(),
|
||||||
"ufp": CuraApplication.getInstance().getMeshFileHandler()
|
"ufp": CuraApplication.getInstance().getMeshFileHandler(),
|
||||||
|
"makerbot": CuraApplication.getInstance().getMeshFileHandler()
|
||||||
}
|
}
|
||||||
|
|
||||||
self._dialog = CuraApplication.getInstance().createQmlComponent(self._dialog_path, {"manager": self._controller})
|
self._dialog = CuraApplication.getInstance().createQmlComponent(self._dialog_path, {"manager": self._controller})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue