Skip to content
This repository has been archived by the owner on May 2, 2023. It is now read-only.

Commit

Permalink
Backward compatible with cura version 4.8 or later
Browse files Browse the repository at this point in the history
  • Loading branch information
macdylan committed Sep 20, 2022
1 parent 0bdc613 commit bb01cff
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions SM2OutputDeviceManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,17 @@
QNetworkAccessManagerOperations = QNetworkAccessManager
QNetworkRequestAttributes = QNetworkRequest
QNetworkReplyNetworkErrors = QNetworkReply
QHostAddressBroadcast = QHostAddress.SpecialAddress.Broadcast
QIPv4Protocol = QAbstractSocket.NetworkLayerProtocol.IPv4Protocol

if hasattr(QHostAddress, 'Broadcast'):
QHostAddressBroadcast = QHostAddress.Broadcast
else:
QHostAddressBroadcast = QHostAddress.SpecialAddress.Broadcast

if hasattr(QAbstractSocket, 'IPv4Protocol'):
QIPv4Protocol = QAbstractSocket.IPv4Protocol
else:
QIPv4Protocol = QAbstractSocket.NetworkLayerProtocol.IPv4Protocol


from cura.CuraApplication import CuraApplication
from cura.PrinterOutput.NetworkedPrinterOutputDevice import NetworkedPrinterOutputDevice, AuthState
Expand Down Expand Up @@ -362,7 +371,7 @@ def _onRequestFinished(self, reply: QNetworkReply) -> None:

if reply.error() not in (
QNetworkReplyNetworkErrors.NoError,
QNetworkReplyNetworkErrors.AuthenticationRequiredError # 204 is No Content, not and error
QNetworkReplyNetworkErrors.AuthenticationRequiredError # 204 is No Content, not an error
):
Logger.log("w", "Error %d from %s", reply.error(), http_url)
self.setConnectionState(ConnectionState.Closed)
Expand Down

0 comments on commit bb01cff

Please sign in to comment.