Solve some review comments

This commit is contained in:
ChrisTerBeke 2019-01-11 16:14:55 +01:00
parent 36e49ee6bb
commit d8b5f75e2a
5 changed files with 16 additions and 25 deletions

View file

@ -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),

View file

@ -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.

View file

@ -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,

View file

@ -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.