klippy: return message category in get_state_message()
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
2d2c09a0a3
commit
014c06f8a2
|
@ -437,7 +437,7 @@ class GCodeParser:
|
||||||
gcmd.ack("T:0")
|
gcmd.ack("T:0")
|
||||||
return
|
return
|
||||||
if not self.is_printer_ready:
|
if not self.is_printer_ready:
|
||||||
raise gcmd.error(self.printer.get_state_message())
|
raise gcmd.error(self.printer.get_state_message()[0])
|
||||||
return
|
return
|
||||||
if not cmd:
|
if not cmd:
|
||||||
logging.debug(gcmd.get_commandline())
|
logging.debug(gcmd.get_commandline())
|
||||||
|
@ -696,7 +696,7 @@ class GCodeParser:
|
||||||
if self.is_printer_ready:
|
if self.is_printer_ready:
|
||||||
self._respond_state("Ready")
|
self._respond_state("Ready")
|
||||||
return
|
return
|
||||||
msg = self.printer.get_state_message()
|
msg = self.printer.get_state_message()[0]
|
||||||
msg = msg.rstrip() + "\nKlipper state: Not ready"
|
msg = msg.rstrip() + "\nKlipper state: Not ready"
|
||||||
raise gcmd.error(msg)
|
raise gcmd.error(msg)
|
||||||
cmd_HELP_when_not_ready = True
|
cmd_HELP_when_not_ready = True
|
||||||
|
|
|
@ -65,7 +65,13 @@ class Printer:
|
||||||
def get_reactor(self):
|
def get_reactor(self):
|
||||||
return self.reactor
|
return self.reactor
|
||||||
def get_state_message(self):
|
def get_state_message(self):
|
||||||
return self.state_message
|
if self.state_message == message_ready:
|
||||||
|
category = "ready"
|
||||||
|
elif self.state_message == message_startup:
|
||||||
|
category = "startup"
|
||||||
|
else:
|
||||||
|
category = "error"
|
||||||
|
return self.state_message, category
|
||||||
def is_shutdown(self):
|
def is_shutdown(self):
|
||||||
return self.in_shutdown_state
|
return self.in_shutdown_state
|
||||||
def _set_state(self, msg):
|
def _set_state(self, msg):
|
||||||
|
|
|
@ -8,7 +8,6 @@ import socket
|
||||||
import errno
|
import errno
|
||||||
import json
|
import json
|
||||||
import homing
|
import homing
|
||||||
from klippy import message_startup, message_ready
|
|
||||||
|
|
||||||
SOCKET_LOCATION = "/tmp/moonraker"
|
SOCKET_LOCATION = "/tmp/moonraker"
|
||||||
|
|
||||||
|
@ -252,15 +251,14 @@ class WebHooks:
|
||||||
if web_request.get_method() != 'GET':
|
if web_request.get_method() != 'GET':
|
||||||
raise web_request.error("Invalid Request Method")
|
raise web_request.error("Invalid Request Method")
|
||||||
start_args = self.printer.get_start_args()
|
start_args = self.printer.get_start_args()
|
||||||
state_message = self.printer.get_state_message()
|
state_message, msg_type = self.printer.get_state_message()
|
||||||
version = start_args['software_version']
|
version = start_args['software_version']
|
||||||
cpu_info = start_args['cpu_info']
|
cpu_info = start_args['cpu_info']
|
||||||
error = state_message != message_startup and \
|
error = msg_type == "error"
|
||||||
state_message != message_ready
|
|
||||||
web_request.send(
|
web_request.send(
|
||||||
{'cpu': cpu_info, 'version': version,
|
{'cpu': cpu_info, 'version': version,
|
||||||
'hostname': socket.gethostname(),
|
'hostname': socket.gethostname(),
|
||||||
'is_ready': state_message == message_ready,
|
'is_ready': msg_type == "ready",
|
||||||
'error_detected': error,
|
'error_detected': error,
|
||||||
'message': state_message})
|
'message': state_message})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue