moonraker: report missing klippy requirements

Moonraker requires that some Klipper objects be configured
and loaded.  This check has always been performed and logged,
now track and report missing requirements.

Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2022-02-10 08:28:51 -05:00
parent b4ddffd5d1
commit 94a2949c00
2 changed files with 15 additions and 5 deletions

View File

@ -25,6 +25,7 @@ from typing import (
Coroutine,
Dict,
List,
Set,
)
if TYPE_CHECKING:
from app import MoonrakerApp
@ -53,6 +54,7 @@ class KlippyConnection:
self.closing: bool = False
self._klippy_info: Dict[str, Any] = {}
self.init_list: List[str] = []
self._missing_reqs: Set[str] = set()
self.init_attempts: int = 0
self._state: str = "disconnected"
self.subscriptions: Dict[Subscribable, Dict[str, Any]] = {}
@ -82,6 +84,10 @@ class KlippyConnection:
def klippy_info(self) -> Dict[str, Any]:
return self._klippy_info
@property
def missing_requirements(self) -> List[str]:
return list(self._missing_reqs)
async def wait_connected(self) -> bool:
if (
self.connection_task is None or
@ -204,6 +210,7 @@ class KlippyConnection:
async def _init_klippy_connection(self) -> bool:
self.init_list = []
self._missing_reqs.clear()
self.init_attempts = 0
self._state = "initializing"
webhooks_err_logged = False
@ -303,14 +310,14 @@ class KlippyConnection:
f"Unable to retrieve Klipper Object List")
return
req_objs = set(["virtual_sdcard", "display_status", "pause_resume"])
missing_objs = req_objs - set(result)
if missing_objs:
err_str = ", ".join([f"[{o}]" for o in missing_objs])
self._missing_reqs = req_objs - set(result)
if self._missing_reqs:
err_str = ", ".join([f"[{o}]" for o in self._missing_reqs])
logging.info(
f"\nWarning, unable to detect the following printer "
f"objects:\n{err_str}\nPlease add the the above sections "
f"to printer.cfg for full Moonraker functionality.")
if "virtual_sdcard" not in missing_objs:
if "virtual_sdcard" not in self._missing_reqs:
# Update the gcode path
query_res = await self.klippy_apis.query_objects(
{'configfile': None}, default=None)
@ -475,6 +482,7 @@ class KlippyConnection:
request.notify(ServerError("Klippy Disconnected", 503))
self.pending_requests = {}
self.subscriptions = {}
self._missing_reqs.clear()
logging.info("Klippy Connection Removed")
await self.server.send_event("server:klippy_disconnect")
if self.server.is_running():

View File

@ -388,6 +388,7 @@ class Server:
if file_manager is not None:
reg_dirs = file_manager.get_registered_dirs()
wsm: WebsocketManager = self.lookup_component('websockets')
mreqs = self.klippy_connection.missing_requirements
return {
'klippy_connected': self.klippy_connection.is_connected(),
'klippy_state': self.klippy_connection.state,
@ -396,7 +397,8 @@ class Server:
'registered_directories': reg_dirs,
'warnings': self.warnings,
'websocket_count': wsm.get_count(),
'moonraker_version': self.app_args['software_version']
'moonraker_version': self.app_args['software_version'],
'missing_klippy_requirements': mreqs
}
async def _handle_config_request(self,