From 391930e2cb5679caa56f42f2dd4db4595beb14fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 12 Jun 2018 13:48:12 +0200 Subject: [PATCH] Fix reported state id --- src/octoprint/printer/standard.py | 39 +++++++++++++++++-------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/src/octoprint/printer/standard.py b/src/octoprint/printer/standard.py index 2ec7174ec..ba02fca9f 100644 --- a/src/octoprint/printer/standard.py +++ b/src/octoprint/printer/standard.py @@ -647,24 +647,29 @@ class Printer(PrinterInterface, return "Unknown state ({})".format(self._protocol.state) def get_state_id(self, state=None, *args, **kwargs): - if self._comm is None: - return "OFFLINE" - else: - if state is None: - state = self._protocol.state - - if state == ProtocolState.DISCONNECTED: + if state is None: + if self._protocol is None: return "OFFLINE" - elif state == ProtocolState.CONNECTING: - return "CONNECTING" - elif state == ProtocolState.CONNECTED: - return "OPERATIONAL" - elif state == ProtocolState.PROCESSING: - return "PRINTING" - elif state == ProtocolState.PAUSED: - return "PAUSED" - elif state == ProtocolState.DISCONNECTED_WITH_ERROR: - return "CLOSED_WITH_ERROR" + state = self._protocol.state + + if state == ProtocolState.DISCONNECTED: + return "OFFLINE" + elif state == ProtocolState.CONNECTING: + return "CONNECTING" + elif state == ProtocolState.CONNECTED: + return "OPERATIONAL" + elif state == ProtocolState.PROCESSING: + return "PRINTING" + elif state == ProtocolState.PAUSING: + return "PAUSING" + elif state == ProtocolState.PAUSED: + return "PAUSED" + elif state == ProtocolState.RESUMING: + return "RESUMING" + elif state == ProtocolState.FINISHING: + return "FINISHING" + elif state == ProtocolState.DISCONNECTED_WITH_ERROR: + return "CLOSED_WITH_ERROR" def get_current_data(self, *args, **kwargs): return util.thaw_frozendict(self._state_monitor.get_current_data())