Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNino van Hooff <ninovanhooff@gmail.com>2020-03-02 13:58:12 +0300
committerNino van Hooff <ninovanhooff@gmail.com>2020-03-02 13:58:12 +0300
commit932b12e66c6be25f3467c505738b8c9a694a7043 (patch)
tree5a8e17faf510f7e5d4945bbcf96bed3f09ecd8a6 /plugins/CuraDrive
parent762f699f6462b861496462152035246aa14e3c19 (diff)
Convert doxygen to rst for DriveApiService
Diffstat (limited to 'plugins/CuraDrive')
-rw-r--r--plugins/CuraDrive/src/DriveApiService.py29
1 files changed, 18 insertions, 11 deletions
diff --git a/plugins/CuraDrive/src/DriveApiService.py b/plugins/CuraDrive/src/DriveApiService.py
index 167eae4424..3a94cf7aa0 100644
--- a/plugins/CuraDrive/src/DriveApiService.py
+++ b/plugins/CuraDrive/src/DriveApiService.py
@@ -25,17 +25,18 @@ from UM.i18n import i18nCatalog
catalog = i18nCatalog("cura")
-## The DriveApiService is responsible for interacting with the CuraDrive API and Cura's backup handling.
@signalemitter
class DriveApiService:
+ """The DriveApiService is responsible for interacting with the CuraDrive API and Cura's backup handling."""
+
BACKUP_URL = "{}/backups".format(Settings.DRIVE_API_URL)
DISK_WRITE_BUFFER_SIZE = 512 * 1024
- # Emit signal when restoring backup started or finished.
restoringStateChanged = Signal()
+ """Emits signal when restoring backup started or finished."""
- # Emit signal when creating backup started or finished.
creatingStateChanged = Signal()
+ """Emits signal when creating backup started or finished."""
def __init__(self) -> None:
self._cura_api = CuraApplication.getInstance().getCuraAPI()
@@ -142,12 +143,15 @@ class DriveApiService:
error_message = catalog.i18nc("@info:backup_status",
"There was an error trying to restore your backup."))
- # Verify the MD5 hash of a file.
- # \param file_path Full path to the file.
- # \param known_hash The known MD5 hash of the file.
- # \return: Success or not.
@staticmethod
def _verifyMd5Hash(file_path: str, known_hash: str) -> bool:
+ """Verify the MD5 hash of a file.
+
+ :param file_path: Full path to the file.
+ :param known_hash: The known MD5 hash of the file.
+ :return: Success or not.
+ """
+
with open(file_path, "rb") as read_backup:
local_md5_hash = base64.b64encode(hashlib.md5(read_backup.read()).digest(), altchars = b"_-").decode("utf-8")
return known_hash == local_md5_hash
@@ -170,11 +174,14 @@ class DriveApiService:
def _onDeleteRequestCompleted(self, reply: QNetworkReply, error: Optional["QNetworkReply.NetworkError"] = None, callable = None):
callable(HttpRequestManager.replyIndicatesSuccess(reply, error))
- # Request a backup upload slot from the API.
- # \param backup_metadata: A dict containing some meta data about the backup.
- # \param backup_size The size of the backup file in bytes.
- # \return: The upload URL for the actual backup file if successful, otherwise None.
def _requestBackupUpload(self, backup_metadata: Dict[str, Any], backup_size: int) -> Optional[str]:
+ """Request a backup upload slot from the API.
+
+ :param backup_metadata: A dict containing some meta data about the backup.
+ :param backup_size: The size of the backup file in bytes.
+ :return: The upload URL for the actual backup file if successful, otherwise None.
+ """
+
access_token = self._cura_api.account.accessToken
if not access_token:
Logger.log("w", "Could not get access token.")