🐛 Fix missing error field on protocol

This commit is contained in:
Gina Häußge committed 2019-03-01 18:09:28 +01:00
1 parent de8be65be7
commit f36a6a0409
2 files changed
+11

No files matched your search

+9
View File
@@ -73,6 +73,7 @@ class Protocol(ListenerAware, TransportListener):
self._logger = logging.getLogger(__name__)
self._protocol_logger = logging.getLogger("PROTOCOL")
self._state = ProtocolState.DISCONNECTED
self._error = None
self._printer_profile = kwargs.get("printer_profile")
self._plugin_manager = kwargs.get("plugin_manager")
@@ -157,6 +158,14 @@ class Protocol(ListenerAware, TransportListener):
if method is not None:
method(old_state)
@property
def error(self):
return self._error
@error.setter
def error(self, new_error):
self._error = new_error
def connect(self, transport, transport_args=None, transport_kwargs=None):
if self.state not in (ProtocolState.DISCONNECTED, ProtocolState.DISCONNECTED_WITH_ERROR):
raise ProtocolAlreadyConnectedError("Already connected, disconnect first")
@@ -945,6 +945,7 @@ class ReprapGcodeProtocol(Protocol, ThreeDPrinterProtocolMixin, MotorControlProt
self.process_protocol_log(message)
# TODO error handling
self.error = "Too many consecutive timeouts"
self.disconnect(error=True)
@@ -1156,6 +1157,7 @@ class ReprapGcodeProtocol(Protocol, ThreeDPrinterProtocolMixin, MotorControlProt
break
else:
# unknown error message
self.error = line
pass
def _on_error_communication(self, error_type):