mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-04-23 22:29:41 +08:00
Qt5->Qt6: More renamed stuff.
part of CURA-8591
This commit is contained in:
parent
97da0b9183
commit
20b435af76
@ -13,7 +13,7 @@ class CameraAnimation(QVariantAnimation):
|
|||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
self._camera_tool = None
|
self._camera_tool = None
|
||||||
self.setDuration(300)
|
self.setDuration(300)
|
||||||
self.setEasingCurve(QEasingCurve.OutQuad)
|
self.setEasingCurve(QEasingCurve.Type.OutQuad)
|
||||||
|
|
||||||
def setCameraTool(self, camera_tool):
|
def setCameraTool(self, camera_tool):
|
||||||
self._camera_tool = camera_tool
|
self._camera_tool = camera_tool
|
||||||
|
@ -161,7 +161,7 @@ class CrashHandler:
|
|||||||
QDesktopServices.openUrl(QUrl.fromLocalFile( path ))
|
QDesktopServices.openUrl(QUrl.fromLocalFile( path ))
|
||||||
|
|
||||||
def _showDetailedReport(self):
|
def _showDetailedReport(self):
|
||||||
self.dialog.exec_()
|
self.dialog.exec()
|
||||||
|
|
||||||
def _createDialog(self):
|
def _createDialog(self):
|
||||||
"""Creates a modal dialog."""
|
"""Creates a modal dialog."""
|
||||||
@ -449,5 +449,5 @@ class CrashHandler:
|
|||||||
def _show(self):
|
def _show(self):
|
||||||
# When the exception is in the skip_exception_types list, the dialog is not created, so we don't need to show it
|
# When the exception is in the skip_exception_types list, the dialog is not created, so we don't need to show it
|
||||||
if self.dialog:
|
if self.dialog:
|
||||||
self.dialog.exec_()
|
self.dialog.exec()
|
||||||
os._exit(1)
|
os._exit(1)
|
||||||
|
@ -870,7 +870,7 @@ class CuraApplication(QtApplication):
|
|||||||
self._auto_save = AutoSave(self)
|
self._auto_save = AutoSave(self)
|
||||||
self._auto_save.initialize()
|
self._auto_save.initialize()
|
||||||
|
|
||||||
self.exec_()
|
self.exec()
|
||||||
|
|
||||||
def __setUpSingleInstanceServer(self):
|
def __setUpSingleInstanceServer(self):
|
||||||
if self._use_single_instance:
|
if self._use_single_instance:
|
||||||
|
@ -8,7 +8,7 @@ from typing import Tuple
|
|||||||
|
|
||||||
class PrintJobPreviewImageProvider(QQuickImageProvider):
|
class PrintJobPreviewImageProvider(QQuickImageProvider):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(QQuickImageProvider.Image)
|
super().__init__(QQuickImageProvider.ImageType.Image)
|
||||||
|
|
||||||
def requestImage(self, id: str, size: QSize) -> Tuple[QImage, QSize]:
|
def requestImage(self, id: str, size: QSize) -> Tuple[QImage, QSize]:
|
||||||
"""Request a new image.
|
"""Request a new image.
|
||||||
|
@ -146,8 +146,8 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice):
|
|||||||
url = QUrl("http://" + self._address + self._api_prefix + target)
|
url = QUrl("http://" + self._address + self._api_prefix + target)
|
||||||
request = QNetworkRequest(url)
|
request = QNetworkRequest(url)
|
||||||
if content_type is not None:
|
if content_type is not None:
|
||||||
request.setHeader(QNetworkRequest.ContentTypeHeader, content_type)
|
request.setHeader(QNetworkRequest.KnownHeaders.ContentTypeHeader, content_type)
|
||||||
request.setHeader(QNetworkRequest.UserAgentHeader, self._user_agent)
|
request.setHeader(QNetworkRequest.KnownHeaders.UserAgentHeader, self._user_agent)
|
||||||
return request
|
return request
|
||||||
|
|
||||||
def createFormPart(self, content_header: str, data: bytes, content_type: Optional[str] = None) -> QHttpPart:
|
def createFormPart(self, content_header: str, data: bytes, content_type: Optional[str] = None) -> QHttpPart:
|
||||||
@ -162,10 +162,10 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice):
|
|||||||
|
|
||||||
if not content_header.startswith("form-data;"):
|
if not content_header.startswith("form-data;"):
|
||||||
content_header = "form-data; " + content_header
|
content_header = "form-data; " + content_header
|
||||||
part.setHeader(QNetworkRequest.ContentDispositionHeader, content_header)
|
part.setHeader(QNetworkRequest.KnownHeaders.ContentDispositionHeader, content_header)
|
||||||
|
|
||||||
if content_type is not None:
|
if content_type is not None:
|
||||||
part.setHeader(QNetworkRequest.ContentTypeHeader, content_type)
|
part.setHeader(QNetworkRequest.KnownHeaders.ContentTypeHeader, content_type)
|
||||||
|
|
||||||
part.setBody(data)
|
part.setBody(data)
|
||||||
return part
|
return part
|
||||||
@ -311,7 +311,7 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice):
|
|||||||
|
|
||||||
def postForm(self, target: str, header_data: str, body_data: bytes, on_finished: Optional[Callable[[QNetworkReply], None]], on_progress: Callable = None) -> None:
|
def postForm(self, target: str, header_data: str, body_data: bytes, on_finished: Optional[Callable[[QNetworkReply], None]], on_progress: Callable = None) -> None:
|
||||||
post_part = QHttpPart()
|
post_part = QHttpPart()
|
||||||
post_part.setHeader(QNetworkRequest.ContentDispositionHeader, header_data)
|
post_part.setHeader(QNetworkRequest.KnownHeaders.ContentDispositionHeader, header_data)
|
||||||
post_part.setBody(body_data)
|
post_part.setBody(body_data)
|
||||||
|
|
||||||
self.postFormWithParts(target, [post_part], on_finished, on_progress)
|
self.postFormWithParts(target, [post_part], on_finished, on_progress)
|
||||||
@ -357,10 +357,10 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice):
|
|||||||
def _handleOnFinished(self, reply: QNetworkReply) -> None:
|
def _handleOnFinished(self, reply: QNetworkReply) -> None:
|
||||||
# Due to garbage collection, we need to cache certain bits of post operations.
|
# Due to garbage collection, we need to cache certain bits of post operations.
|
||||||
# As we don't want to keep them around forever, delete them if we get a reply.
|
# As we don't want to keep them around forever, delete them if we get a reply.
|
||||||
if reply.operation() == QNetworkAccessManager.PostOperation:
|
if reply.operation() == QNetworkAccessManager.Operation.PostOperation:
|
||||||
self._clearCachedMultiPart(reply)
|
self._clearCachedMultiPart(reply)
|
||||||
|
|
||||||
if reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) is None:
|
if reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute) is None:
|
||||||
# No status code means it never even reached remote.
|
# No status code means it never even reached remote.
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -148,10 +148,10 @@ def exceptHook(hook_type, value, traceback):
|
|||||||
# The flag "CuraApplication.Created" is set to True when CuraApplication finishes its constructor call.
|
# The flag "CuraApplication.Created" is set to True when CuraApplication finishes its constructor call.
|
||||||
#
|
#
|
||||||
# Before the "started" flag is set to True, the Qt event loop has not started yet. The event loop is a blocking
|
# Before the "started" flag is set to True, the Qt event loop has not started yet. The event loop is a blocking
|
||||||
# call to the QApplication.exec_(). In this case, we need to:
|
# call to the QApplication.exec(). In this case, we need to:
|
||||||
# 1. Remove all scheduled events so no more unnecessary events will be processed, such as loading the main dialog,
|
# 1. Remove all scheduled events so no more unnecessary events will be processed, such as loading the main dialog,
|
||||||
# loading the machine, etc.
|
# loading the machine, etc.
|
||||||
# 2. Start the Qt event loop with exec_() and show the Crash Dialog.
|
# 2. Start the Qt event loop with exec() and show the Crash Dialog.
|
||||||
#
|
#
|
||||||
# If the application has finished its initialization and was running fine, and then something causes a crash,
|
# If the application has finished its initialization and was running fine, and then something causes a crash,
|
||||||
# we run the old routine to show the Crash Dialog.
|
# we run the old routine to show the Crash Dialog.
|
||||||
@ -164,7 +164,7 @@ def exceptHook(hook_type, value, traceback):
|
|||||||
if not has_started:
|
if not has_started:
|
||||||
CuraApplication.getInstance().removePostedEvents(None)
|
CuraApplication.getInstance().removePostedEvents(None)
|
||||||
_crash_handler.early_crash_dialog.show()
|
_crash_handler.early_crash_dialog.show()
|
||||||
sys.exit(CuraApplication.getInstance().exec_())
|
sys.exit(CuraApplication.getInstance().exec())
|
||||||
else:
|
else:
|
||||||
_crash_handler.show()
|
_crash_handler.show()
|
||||||
else:
|
else:
|
||||||
|
@ -53,7 +53,7 @@ class RestoreBackupJob(Job):
|
|||||||
def _onRestoreRequestCompleted(self, reply: QNetworkReply, error: Optional["QNetworkReply.NetworkError"] = None) -> None:
|
def _onRestoreRequestCompleted(self, reply: QNetworkReply, error: Optional["QNetworkReply.NetworkError"] = None) -> None:
|
||||||
if not HttpRequestManager.replyIndicatesSuccess(reply, error):
|
if not HttpRequestManager.replyIndicatesSuccess(reply, error):
|
||||||
Logger.warning("Requesting backup failed, response code %s while trying to connect to %s",
|
Logger.warning("Requesting backup failed, response code %s while trying to connect to %s",
|
||||||
reply.attribute(QNetworkRequest.HttpStatusCodeAttribute), reply.url())
|
reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute), reply.url())
|
||||||
self.restore_backup_error_message = self.DEFAULT_ERROR_MESSAGE
|
self.restore_backup_error_message = self.DEFAULT_ERROR_MESSAGE
|
||||||
self._job_done.set()
|
self._job_done.set()
|
||||||
return
|
return
|
||||||
|
@ -120,9 +120,9 @@ class DFFileUploader:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
Logger.log("i", "Finished callback %s %s",
|
Logger.log("i", "Finished callback %s %s",
|
||||||
reply.attribute(QNetworkRequest.HttpStatusCodeAttribute), reply.url().toString())
|
reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute), reply.url().toString())
|
||||||
|
|
||||||
status_code = reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) # type: Optional[int]
|
status_code = reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute) # type: Optional[int]
|
||||||
if not status_code:
|
if not status_code:
|
||||||
Logger.log("e", "Reply contained no status code.")
|
Logger.log("e", "Reply contained no status code.")
|
||||||
self._onUploadError(reply, None)
|
self._onUploadError(reply, None)
|
||||||
|
@ -228,7 +228,7 @@ class DigitalFactoryApiClient:
|
|||||||
self._anti_gc_callbacks.remove(parse)
|
self._anti_gc_callbacks.remove(parse)
|
||||||
|
|
||||||
# Don't try to parse the reply if we didn't get one
|
# Don't try to parse the reply if we didn't get one
|
||||||
if reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) is None:
|
if reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute) is None:
|
||||||
if on_error is not None:
|
if on_error is not None:
|
||||||
on_error()
|
on_error()
|
||||||
return
|
return
|
||||||
@ -250,7 +250,7 @@ class DigitalFactoryApiClient:
|
|||||||
:return: A tuple with a status code and a dictionary.
|
:return: A tuple with a status code and a dictionary.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
status_code = reply.attribute(QNetworkRequest.HttpStatusCodeAttribute)
|
status_code = reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute)
|
||||||
try:
|
try:
|
||||||
response = bytes(reply.readAll()).decode()
|
response = bytes(reply.readAll()).decode()
|
||||||
return status_code, json.loads(response)
|
return status_code, json.loads(response)
|
||||||
|
@ -289,7 +289,7 @@ class SliceInfo(QObject, Extension):
|
|||||||
Logger.logException("e", "Exception raised while sending slice info.") # But we should be notified about these problems of course.
|
Logger.logException("e", "Exception raised while sending slice info.") # But we should be notified about these problems of course.
|
||||||
|
|
||||||
def _onRequestFinished(self, reply: "QNetworkReply") -> None:
|
def _onRequestFinished(self, reply: "QNetworkReply") -> None:
|
||||||
status_code = reply.attribute(QNetworkRequest.HttpStatusCodeAttribute)
|
status_code = reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute)
|
||||||
if status_code == 200:
|
if status_code == 200:
|
||||||
Logger.log("i", "SliceInfo sent successfully")
|
Logger.log("i", "SliceInfo sent successfully")
|
||||||
return
|
return
|
||||||
|
@ -70,10 +70,10 @@ class CloudPackageChecker(QObject):
|
|||||||
scope = self._scope)
|
scope = self._scope)
|
||||||
|
|
||||||
def _onUserPackagesRequestFinished(self, reply: "QNetworkReply", error: Optional["QNetworkReply.NetworkError"] = None) -> None:
|
def _onUserPackagesRequestFinished(self, reply: "QNetworkReply", error: Optional["QNetworkReply.NetworkError"] = None) -> None:
|
||||||
if error is not None or reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) != 200:
|
if error is not None or reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute) != 200:
|
||||||
Logger.log("w",
|
Logger.log("w",
|
||||||
"Requesting user packages failed, response code %s while trying to connect to %s",
|
"Requesting user packages failed, response code %s while trying to connect to %s",
|
||||||
reply.attribute(QNetworkRequest.HttpStatusCodeAttribute), reply.url())
|
reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute), reply.url())
|
||||||
self._application.getCuraAPI().account.setSyncState(self.SYNC_SERVICE_NAME, SyncState.ERROR)
|
self._application.getCuraAPI().account.setSyncState(self.SYNC_SERVICE_NAME, SyncState.ERROR)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -589,11 +589,11 @@ class Toolbox(QObject, Extension):
|
|||||||
self.setViewPage("errored")
|
self.setViewPage("errored")
|
||||||
|
|
||||||
def _onDataRequestFinished(self, request_type: str, reply: "QNetworkReply") -> None:
|
def _onDataRequestFinished(self, request_type: str, reply: "QNetworkReply") -> None:
|
||||||
if reply.operation() != QNetworkAccessManager.GetOperation:
|
if reply.operation() != QNetworkAccessManager.Operation.GetOperation:
|
||||||
Logger.log("e", "_onDataRequestFinished() only handles GET requests but got [%s] instead", reply.operation())
|
Logger.log("e", "_onDataRequestFinished() only handles GET requests but got [%s] instead", reply.operation())
|
||||||
return
|
return
|
||||||
|
|
||||||
http_status_code = reply.attribute(QNetworkRequest.HttpStatusCodeAttribute)
|
http_status_code = reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute)
|
||||||
if http_status_code != 200:
|
if http_status_code != 200:
|
||||||
Logger.log("e", "Request type [%s] got non-200 HTTP response: [%s]", http_status_code)
|
Logger.log("e", "Request type [%s] got non-200 HTTP response: [%s]", http_status_code)
|
||||||
self.setViewPage("errored")
|
self.setViewPage("errored")
|
||||||
@ -650,7 +650,7 @@ class Toolbox(QObject, Extension):
|
|||||||
def _onDownloadFinished(self, reply: "QNetworkReply") -> None:
|
def _onDownloadFinished(self, reply: "QNetworkReply") -> None:
|
||||||
self.resetDownload()
|
self.resetDownload()
|
||||||
|
|
||||||
if reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) != 200:
|
if reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute) != 200:
|
||||||
try:
|
try:
|
||||||
reply_error = json.loads(reply.readAll().data().decode("utf-8"))
|
reply_error = json.loads(reply.readAll().data().decode("utf-8"))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -165,7 +165,7 @@ class CloudApiClient:
|
|||||||
|
|
||||||
request = QNetworkRequest(QUrl(path))
|
request = QNetworkRequest(QUrl(path))
|
||||||
if content_type:
|
if content_type:
|
||||||
request.setHeader(QNetworkRequest.ContentTypeHeader, content_type)
|
request.setHeader(QNetworkRequest.KnownHeaders.ContentTypeHeader, content_type)
|
||||||
access_token = self._account.accessToken
|
access_token = self._account.accessToken
|
||||||
if access_token:
|
if access_token:
|
||||||
request.setRawHeader(b"Authorization", "Bearer {}".format(access_token).encode())
|
request.setRawHeader(b"Authorization", "Bearer {}".format(access_token).encode())
|
||||||
@ -179,7 +179,7 @@ class CloudApiClient:
|
|||||||
:return: A tuple with a status code and a dictionary.
|
:return: A tuple with a status code and a dictionary.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
status_code = reply.attribute(QNetworkRequest.HttpStatusCodeAttribute)
|
status_code = reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute)
|
||||||
try:
|
try:
|
||||||
response = bytes(reply.readAll()).decode()
|
response = bytes(reply.readAll()).decode()
|
||||||
return status_code, json.loads(response)
|
return status_code, json.loads(response)
|
||||||
@ -233,7 +233,7 @@ class CloudApiClient:
|
|||||||
self._anti_gc_callbacks.remove(parse)
|
self._anti_gc_callbacks.remove(parse)
|
||||||
|
|
||||||
# Don't try to parse the reply if we didn't get one
|
# Don't try to parse the reply if we didn't get one
|
||||||
if reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) is None:
|
if reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute) is None:
|
||||||
if on_error is not None:
|
if on_error is not None:
|
||||||
on_error()
|
on_error()
|
||||||
return
|
return
|
||||||
|
@ -272,7 +272,7 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
|||||||
"""
|
"""
|
||||||
Displays a message when an error occurs specific to uploading print job (i.e. queue is full).
|
Displays a message when an error occurs specific to uploading print job (i.e. queue is full).
|
||||||
"""
|
"""
|
||||||
error_code = reply.attribute(QNetworkRequest.HttpStatusCodeAttribute)
|
error_code = reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute)
|
||||||
if error_code == 409:
|
if error_code == 409:
|
||||||
PrintJobUploadQueueFullMessage().show()
|
PrintJobUploadQueueFullMessage().show()
|
||||||
else:
|
else:
|
||||||
|
@ -106,9 +106,9 @@ class ToolPathUploader:
|
|||||||
"""Checks whether a chunk of data was uploaded successfully, starting the next chunk if needed."""
|
"""Checks whether a chunk of data was uploaded successfully, starting the next chunk if needed."""
|
||||||
|
|
||||||
Logger.log("i", "Finished callback %s %s",
|
Logger.log("i", "Finished callback %s %s",
|
||||||
reply.attribute(QNetworkRequest.HttpStatusCodeAttribute), reply.url().toString())
|
reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute), reply.url().toString())
|
||||||
|
|
||||||
status_code = reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) # type: Optional[int]
|
status_code = reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute) # type: Optional[int]
|
||||||
if not status_code:
|
if not status_code:
|
||||||
Logger.log("e", "Reply contained no status code.")
|
Logger.log("e", "Reply contained no status code.")
|
||||||
self._errorCallback(reply, None)
|
self._errorCallback(reply, None)
|
||||||
|
@ -42,6 +42,6 @@ class UM3PrintJobOutputModel(PrintJobOutputModel):
|
|||||||
def _onImageLoaded(self, reply: QNetworkReply, error: Optional["QNetworkReply.NetworkError"] = None) -> None:
|
def _onImageLoaded(self, reply: QNetworkReply, error: Optional["QNetworkReply.NetworkError"] = None) -> None:
|
||||||
if not HttpRequestManager.replyIndicatesSuccess(reply, error):
|
if not HttpRequestManager.replyIndicatesSuccess(reply, error):
|
||||||
Logger.warning("Requesting preview image failed, response code {0} while trying to connect to {1}".format(
|
Logger.warning("Requesting preview image failed, response code {0} while trying to connect to {1}".format(
|
||||||
reply.attribute(QNetworkRequest.HttpStatusCodeAttribute), reply.url()))
|
reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute), reply.url()))
|
||||||
return
|
return
|
||||||
self.updatePreviewImageData(reply.readAll())
|
self.updatePreviewImageData(reply.readAll())
|
||||||
|
@ -118,9 +118,9 @@ class ClusterApiClient:
|
|||||||
"""
|
"""
|
||||||
url = QUrl("http://" + self._address + path)
|
url = QUrl("http://" + self._address + path)
|
||||||
request = QNetworkRequest(url)
|
request = QNetworkRequest(url)
|
||||||
request.setAttribute(QNetworkRequest.FollowRedirectsAttribute, True)
|
request.setAttribute(QNetworkRequest.Attribute.RedirectPolicyAttribute, QNetworkRequest.RedirectPolicy.ManualRedirectPolicy)
|
||||||
if content_type:
|
if content_type:
|
||||||
request.setHeader(QNetworkRequest.ContentTypeHeader, content_type)
|
request.setHeader(QNetworkRequest.KnownHeaders.ContentTypeHeader, content_type)
|
||||||
return request
|
return request
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -130,7 +130,7 @@ class ClusterApiClient:
|
|||||||
:param reply: The reply from the server.
|
:param reply: The reply from the server.
|
||||||
:return: A tuple with a status code and a dictionary.
|
:return: A tuple with a status code and a dictionary.
|
||||||
"""
|
"""
|
||||||
status_code = reply.attribute(QNetworkRequest.HttpStatusCodeAttribute)
|
status_code = reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute)
|
||||||
try:
|
try:
|
||||||
response = bytes(reply.readAll()).decode()
|
response = bytes(reply.readAll()).decode()
|
||||||
return status_code, json.loads(response)
|
return status_code, json.loads(response)
|
||||||
@ -173,7 +173,7 @@ class ClusterApiClient:
|
|||||||
self._anti_gc_callbacks.remove(parse)
|
self._anti_gc_callbacks.remove(parse)
|
||||||
|
|
||||||
# Don't try to parse the reply if we didn't get one
|
# Don't try to parse the reply if we didn't get one
|
||||||
if reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) is None:
|
if reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute) is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
if reply.error() > 0:
|
if reply.error() > 0:
|
||||||
|
@ -152,7 +152,7 @@ class SendMaterialJob(Job):
|
|||||||
def _sendingFinished(self, reply: QNetworkReply) -> None:
|
def _sendingFinished(self, reply: QNetworkReply) -> None:
|
||||||
"""Check a reply from an upload to the printer and log an error when the call failed"""
|
"""Check a reply from an upload to the printer and log an error when the call failed"""
|
||||||
|
|
||||||
if reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) != 200:
|
if reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute) != 200:
|
||||||
Logger.log("w", "Error while syncing material: %s", reply.errorString())
|
Logger.log("w", "Error while syncing material: %s", reply.errorString())
|
||||||
return
|
return
|
||||||
body = reply.readAll().data().decode('utf8')
|
body = reply.readAll().data().decode('utf8')
|
||||||
|
@ -43,7 +43,7 @@ def test_post():
|
|||||||
|
|
||||||
# Create a fake reply (we can't use a QReply, since those are abstract C++)
|
# Create a fake reply (we can't use a QReply, since those are abstract C++)
|
||||||
reply = MagicMock()
|
reply = MagicMock()
|
||||||
reply.operation = MagicMock(return_value=QNetworkAccessManager.PostOperation)
|
reply.operation = MagicMock(return_value=QNetworkAccessManager.Operation.PostOperation)
|
||||||
reply.url = MagicMock(return_value=QUrl("127.0.0.1"))
|
reply.url = MagicMock(return_value=QUrl("127.0.0.1"))
|
||||||
mocked_network_manager.post = MagicMock(return_value = reply)
|
mocked_network_manager.post = MagicMock(return_value = reply)
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ def test_get():
|
|||||||
|
|
||||||
# Create a fake reply (we can't use a QReply, since those are abstract C++)
|
# Create a fake reply (we can't use a QReply, since those are abstract C++)
|
||||||
reply = MagicMock()
|
reply = MagicMock()
|
||||||
reply.operation = MagicMock(return_value=QNetworkAccessManager.PostOperation)
|
reply.operation = MagicMock(return_value=QNetworkAccessManager.Operation.PostOperation)
|
||||||
reply.url = MagicMock(return_value=QUrl("127.0.0.1"))
|
reply.url = MagicMock(return_value=QUrl("127.0.0.1"))
|
||||||
mocked_network_manager.get = MagicMock(return_value=reply)
|
mocked_network_manager.get = MagicMock(return_value=reply)
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ def test_delete():
|
|||||||
|
|
||||||
# Create a fake reply (we can't use a QReply, since those are abstract C++)
|
# Create a fake reply (we can't use a QReply, since those are abstract C++)
|
||||||
reply = MagicMock()
|
reply = MagicMock()
|
||||||
reply.operation = MagicMock(return_value=QNetworkAccessManager.PostOperation)
|
reply.operation = MagicMock(return_value=QNetworkAccessManager.Operation.PostOperation)
|
||||||
reply.url = MagicMock(return_value=QUrl("127.0.0.1"))
|
reply.url = MagicMock(return_value=QUrl("127.0.0.1"))
|
||||||
mocked_network_manager.deleteResource = MagicMock(return_value=reply)
|
mocked_network_manager.deleteResource = MagicMock(return_value=reply)
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ def test_put():
|
|||||||
|
|
||||||
# Create a fake reply (we can't use a QReply, since those are abstract C++)
|
# Create a fake reply (we can't use a QReply, since those are abstract C++)
|
||||||
reply = MagicMock()
|
reply = MagicMock()
|
||||||
reply.operation = MagicMock(return_value=QNetworkAccessManager.PostOperation)
|
reply.operation = MagicMock(return_value=QNetworkAccessManager.Operation.PostOperation)
|
||||||
reply.url = MagicMock(return_value=QUrl("127.0.0.1"))
|
reply.url = MagicMock(return_value=QUrl("127.0.0.1"))
|
||||||
mocked_network_manager.put = MagicMock(return_value = reply)
|
mocked_network_manager.put = MagicMock(return_value = reply)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user