mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-13 01:37:51 -06:00
Added CuraDirve plugin to Cura build
CURA-6005
This commit is contained in:
parent
3db3203e0d
commit
c62cb84c75
43 changed files with 1287 additions and 1 deletions
39
plugins/CuraDrive/src/UploadBackupJob.py
Normal file
39
plugins/CuraDrive/src/UploadBackupJob.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
# Copyright (c) 2018 Ultimaker B.V.
|
||||
import requests
|
||||
|
||||
from UM.Job import Job
|
||||
from UM.Logger import Logger
|
||||
from UM.Message import Message
|
||||
|
||||
from .Settings import Settings
|
||||
|
||||
|
||||
class UploadBackupJob(Job):
|
||||
"""
|
||||
This job is responsible for uploading the backup file to cloud storage.
|
||||
As it can take longer than some other tasks, we schedule this using a Cura Job.
|
||||
"""
|
||||
|
||||
def __init__(self, signed_upload_url: str, backup_zip: bytes):
|
||||
super().__init__()
|
||||
self._signed_upload_url = signed_upload_url
|
||||
self._backup_zip = backup_zip
|
||||
self._upload_success = False
|
||||
self.backup_upload_error_message = ""
|
||||
|
||||
def run(self):
|
||||
Message(Settings.translatable_messages["uploading_backup"], title = Settings.MESSAGE_TITLE,
|
||||
lifetime = 10).show()
|
||||
|
||||
backup_upload = requests.put(self._signed_upload_url, data = self._backup_zip)
|
||||
if backup_upload.status_code not in (200, 201):
|
||||
self.backup_upload_error_message = backup_upload.text
|
||||
Logger.log("w", "Could not upload backup file: %s", backup_upload.text)
|
||||
Message(Settings.translatable_messages["uploading_backup_error"], title = Settings.MESSAGE_TITLE,
|
||||
lifetime = 10).show()
|
||||
else:
|
||||
self._upload_success = True
|
||||
Message(Settings.translatable_messages["uploading_backup_success"], title = Settings.MESSAGE_TITLE,
|
||||
lifetime = 10).show()
|
||||
|
||||
self.finished.emit(self)
|
Loading…
Add table
Add a link
Reference in a new issue