Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to sip 6 #776

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions UM/Backend/Backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def startEngine(self):

def close(self):
if self._socket:
while self._socket.getState() == Arcus.SocketState.Opening:
while self._socket.getState() == Arcus.SocketState.SocketState.Opening:
sleep(0.1)
self._socket.close()

Expand Down Expand Up @@ -174,27 +174,27 @@ def _onSocketStateChanged(self, state):
"""Private socket state changed handler."""

self._logSocketState(state)
if state == Arcus.SocketState.Listening:
if state == Arcus.SocketState.SocketState.Listening:
if not UM.Application.Application.getInstance().getUseExternalBackend():
self.startEngine()
elif state == Arcus.SocketState.Connected:
elif state == Arcus.SocketState.SocketState.Connected:
Logger.log("d", "Backend connected on port %s", self._port)
self.backendConnected.emit()

def _logSocketState(self, state):
"""Debug function created to provide more info for CURA-2127"""

if state == Arcus.SocketState.Listening:
if state == Arcus.SocketState.SocketState.Listening:
Logger.log("d", "Socket state changed to Listening")
elif state == Arcus.SocketState.Connecting:
elif state == Arcus.SocketState.SocketState.Connecting:
Logger.log("d", "Socket state changed to Connecting")
elif state == Arcus.SocketState.Connected:
elif state == Arcus.SocketState.SocketState.Connected:
Logger.log("d", "Socket state changed to Connected")
elif state == Arcus.SocketState.Error:
elif state == Arcus.SocketState.SocketState.Error:
Logger.log("d", "Socket state changed to Error")
elif state == Arcus.SocketState.Closing:
elif state == Arcus.SocketState.SocketState.Closing:
Logger.log("d", "Socket state changed to Closing")
elif state == Arcus.SocketState.Closed:
elif state == Arcus.SocketState.SocketState.Closed:
Logger.log("d", "Socket state changed to Closed")

def _onMessageReceived(self):
Expand Down Expand Up @@ -233,7 +233,7 @@ def _createSocket(self, protocol_file):
self._socket.messageReceived.disconnect(self._onMessageReceived)
self._socket.error.disconnect(self._onSocketError)
# Hack for (at least) Linux. If the socket is connecting, the close will deadlock.
while self._socket.getState() == Arcus.SocketState.Opening:
while self._socket.getState() == Arcus.SocketState.SocketState.Opening:
sleep(0.1)
# If the error occurred due to parsing, both connections believe that connection is okay.
# So we need to force a close.
Expand Down
4 changes: 2 additions & 2 deletions tests/TestBackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ def test_startEngineWithoutCommand(backend):
def test__onSocketStateChanged_listening(backend):
backend.startEngine = MagicMock()
with patch("UM.Application.Application.getInstance"):
backend._onSocketStateChanged(Arcus.SocketState.Listening)
backend._onSocketStateChanged(Arcus.SocketState.SocketState.Listening)
assert backend.startEngine.called_once_with()


def test_onSocketStateChanged_connected(backend):
backend.backendConnected = MagicMock()
backend._onSocketStateChanged(Arcus.SocketState.Connected)
backend._onSocketStateChanged(Arcus.SocketState.SocketState.Connected)
assert backend.backendConnected.emit.called_once_with()


Expand Down