mirror of https://github.com/Desuuuu/klipper.git
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")
|
||||
return
|
||||
if not self.is_printer_ready:
|
||||
raise gcmd.error(self.printer.get_state_message())
|
||||
raise gcmd.error(self.printer.get_state_message()[0])
|
||||
return
|
||||
if not cmd:
|
||||
logging.debug(gcmd.get_commandline())
|
||||
|
@ -696,7 +696,7 @@ class GCodeParser:
|
|||
if self.is_printer_ready:
|
||||
self._respond_state("Ready")
|
||||
return
|
||||
msg = self.printer.get_state_message()
|
||||
msg = self.printer.get_state_message()[0]
|
||||
msg = msg.rstrip() + "\nKlipper state: Not ready"
|
||||
raise gcmd.error(msg)
|
||||
cmd_HELP_when_not_ready = True
|
||||
|
|
|
@ -65,7 +65,13 @@ class Printer:
|
|||
def get_reactor(self):
|
||||
return self.reactor
|
||||
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):
|
||||
return self.in_shutdown_state
|
||||
def _set_state(self, msg):
|
||||
|
|
|
@ -8,7 +8,6 @@ import socket
|
|||
import errno
|
||||
import json
|
||||
import homing
|
||||
from klippy import message_startup, message_ready
|
||||
|
||||
SOCKET_LOCATION = "/tmp/moonraker"
|
||||
|
||||
|
@ -252,15 +251,14 @@ class WebHooks:
|
|||
if web_request.get_method() != 'GET':
|
||||
raise web_request.error("Invalid Request Method")
|
||||
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']
|
||||
cpu_info = start_args['cpu_info']
|
||||
error = state_message != message_startup and \
|
||||
state_message != message_ready
|
||||
error = msg_type == "error"
|
||||
web_request.send(
|
||||
{'cpu': cpu_info, 'version': version,
|
||||
'hostname': socket.gethostname(),
|
||||
'is_ready': state_message == message_ready,
|
||||
'is_ready': msg_type == "ready",
|
||||
'error_detected': error,
|
||||
'message': state_message})
|
||||
|
||||
|
|
Loading…
Reference in New Issue