mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-09 07:56:22 -06:00
Solve some review comments
This commit is contained in:
parent
36e49ee6bb
commit
d8b5f75e2a
5 changed files with 16 additions and 25 deletions
|
@ -194,11 +194,11 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice):
|
|||
assert (self._manager is not None)
|
||||
|
||||
## Sends a put request to the given path.
|
||||
# url: The path after the API prefix.
|
||||
# data: The data to be sent in the body
|
||||
# content_type: The content type of the body data.
|
||||
# on_finished: The function to call when the response is received.
|
||||
# on_progress: The function to call when the progress changes. Parameters are bytes_sent / bytes_total.
|
||||
# \param url: The path after the API prefix.
|
||||
# \param data: The data to be sent in the body
|
||||
# \param content_type: The content type of the body data.
|
||||
# \param on_finished: The function to call when the response is received.
|
||||
# \param on_progress: The function to call when the progress changes. Parameters are bytes_sent / bytes_total.
|
||||
def put(self, url: str, data: Union[str, bytes], content_type: Optional[str] = None,
|
||||
on_finished: Optional[Callable[[QNetworkReply], None]] = None,
|
||||
on_progress: Optional[Callable[[int, int], None]] = None) -> None:
|
||||
|
@ -219,8 +219,8 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice):
|
|||
reply.uploadProgress.connect(on_progress)
|
||||
|
||||
## Sends a delete request to the given path.
|
||||
# url: The path after the API prefix.
|
||||
# on_finished: The function to be call when the response is received.
|
||||
# \param url: The path after the API prefix.
|
||||
# \param on_finished: The function to be call when the response is received.
|
||||
def delete(self, url: str, on_finished: Optional[Callable[[QNetworkReply], None]]) -> None:
|
||||
self._validateManager()
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ class CloudApiClient:
|
|||
self._account = account
|
||||
self._on_error = on_error
|
||||
self._upload = None # type: Optional[MeshUploader]
|
||||
# in order to avoid garbage collection we keep the callbacks in this list.
|
||||
# In order to avoid garbage collection we keep the callbacks in this list.
|
||||
self._anti_gc_callbacks = [] # type: List[Callable[[], None]]
|
||||
|
||||
## Gets the account used for the API.
|
||||
|
@ -105,7 +105,6 @@ class CloudApiClient:
|
|||
request.setHeader(QNetworkRequest.ContentTypeHeader, content_type)
|
||||
if self._account.isLoggedIn:
|
||||
request.setRawHeader(b"Authorization", "Bearer {}".format(self._account.accessToken).encode())
|
||||
# Logger.log("i", "Created request for URL %s. Logged in = %s", path, self._account.isLoggedIn)
|
||||
return request
|
||||
|
||||
## Parses the given JSON network reply into a status code and a dictionary, handling unexpected errors as well.
|
||||
|
@ -116,7 +115,6 @@ class CloudApiClient:
|
|||
status_code = reply.attribute(QNetworkRequest.HttpStatusCodeAttribute)
|
||||
try:
|
||||
response = bytes(reply.readAll()).decode()
|
||||
# Logger.log("i", "Received a reply %s from %s with %s", status_code, reply.url().toString(), response)
|
||||
return status_code, json.loads(response)
|
||||
except (UnicodeDecodeError, JSONDecodeError, ValueError) as err:
|
||||
error = CloudError(code=type(err).__name__, title=str(err), http_code=str(status_code),
|
||||
|
|
|
@ -107,7 +107,7 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
|
|||
## Disconnects the device
|
||||
def disconnect(self) -> None:
|
||||
super().disconnect()
|
||||
Logger.log("i", "Disconnected to cluster %s", self.key)
|
||||
Logger.log("i", "Disconnected from cluster %s", self.key)
|
||||
CuraApplication.getInstance().getBackend().backendStateChange.disconnect(self._onBackendStateChange)
|
||||
|
||||
## Resets the print job that was uploaded to force a new upload, runs whenever the user re-slices.
|
||||
|
|
|
@ -4,20 +4,15 @@ from UM import i18nCatalog
|
|||
from UM.Message import Message
|
||||
|
||||
|
||||
## Class that contains all the translations for this module.
|
||||
class T:
|
||||
_I18N_CATALOG = i18nCatalog("cura")
|
||||
|
||||
SENDING_DATA_TEXT = _I18N_CATALOG.i18nc("@info:status", "Sending data to remote cluster")
|
||||
SENDING_DATA_TITLE = _I18N_CATALOG.i18nc("@info:status", "Sending data to remote cluster")
|
||||
I18N_CATALOG = i18nCatalog("cura")
|
||||
|
||||
|
||||
## Class responsible for showing a progress message while a mesh is being uploaded to the cloud.
|
||||
class CloudProgressMessage(Message):
|
||||
def __init__(self):
|
||||
super().__init__(
|
||||
text = T.SENDING_DATA_TEXT,
|
||||
title = T.SENDING_DATA_TITLE,
|
||||
text = I18N_CATALOG.i18nc("@info:status", "Sending data to remote cluster"),
|
||||
title = I18N_CATALOG.i18nc("@info:status", "Sending data to remote cluster"),
|
||||
progress = -1,
|
||||
lifetime = 0,
|
||||
dismissable = False,
|
||||
|
|
|
@ -13,11 +13,7 @@ from UM.i18n import i18nCatalog
|
|||
from cura.CuraApplication import CuraApplication
|
||||
|
||||
|
||||
## Class that contains all the translations for this module.
|
||||
class T:
|
||||
# The translation catalog for this module.
|
||||
_I18N_CATALOG = i18nCatalog("cura")
|
||||
NO_FORMATS_AVAILABLE = _I18N_CATALOG.i18nc("@info:status", "There are no file formats available to write with!")
|
||||
I18N_CATALOG = i18nCatalog("cura")
|
||||
|
||||
|
||||
## This class is responsible for choosing the formats used by the connected clusters.
|
||||
|
@ -106,7 +102,9 @@ class MeshFormatHandler:
|
|||
|
||||
if len(file_formats) == 0:
|
||||
Logger.log("e", "There are no file formats available to write with!")
|
||||
raise OutputDeviceError.WriteRequestFailedError(T.NO_FORMATS_AVAILABLE)
|
||||
raise OutputDeviceError.WriteRequestFailedError(
|
||||
I18N_CATALOG.i18nc("@info:status", "There are no file formats available to write with!")
|
||||
)
|
||||
return file_formats[0]
|
||||
|
||||
## Gets the file writer for the given file handler and mime type.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue