From 9a466f3b224f18d6f91909b675c2db8d113573c9 Mon Sep 17 00:00:00 2001 From: Eric Callahan Date: Tue, 18 Oct 2022 06:11:15 -0400 Subject: [PATCH] server: improve warning formatting Introduce a "raw" parameter for /server/info that defaults to False. Front ends that do not wish to recieve warnings with html line breaks may set this parameter to True, otherwise newlines will be replaced with "
". Signed-off-by: Eric Callahan --- moonraker/moonraker.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/moonraker/moonraker.py b/moonraker/moonraker.py index e03e57b..a48c322 100755 --- a/moonraker/moonraker.py +++ b/moonraker/moonraker.py @@ -399,6 +399,7 @@ class Server: async def _handle_info_request(self, web_request: WebRequest ) -> Dict[str, Any]: + raw = web_request.get_boolean("raw", False) file_manager: Optional[FileManager] = self.lookup_component( 'file_manager', None) reg_dirs = [] @@ -406,13 +407,19 @@ class Server: reg_dirs = file_manager.get_registered_dirs() wsm: WebsocketManager = self.lookup_component('websockets') mreqs = self.klippy_connection.missing_requirements + if raw: + warnings = list(self.warnings.values()) + else: + warnings = [ + w.replace("\n", "
") for w in self.warnings.values() + ] return { 'klippy_connected': self.klippy_connection.is_connected(), 'klippy_state': self.klippy_connection.state, 'components': list(self.components.keys()), 'failed_components': self.failed_components, 'registered_directories': reg_dirs, - 'warnings': list(self.warnings.values()), + 'warnings': warnings, 'websocket_count': wsm.get_count(), 'moonraker_version': self.app_args['software_version'], 'missing_klippy_requirements': mreqs,