From 3047fde8123617318df9277e251fbb0763d319dd Mon Sep 17 00:00:00 2001 From: alfrix Date: Tue, 29 Nov 2022 08:12:43 -0300 Subject: [PATCH] cleanup quotes in connection status messages --- ks_includes/KlippyRest.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/ks_includes/KlippyRest.py b/ks_includes/KlippyRest.py index b70d6234..f007d8b2 100644 --- a/ks_includes/KlippyRest.py +++ b/ks_includes/KlippyRest.py @@ -59,20 +59,17 @@ class KlippyRest: if data: self.status = '' else: - logging.error(self.status) + logging.error(self.status.replace('\n', '>>')) return data @staticmethod def format_status(status): try: - rep = {"HTTPConnectionPool": "", "/server/info ": "", "Caused by ": "", "(": "", ")": "", ": ": "\n"} + rep = {"HTTPConnectionPool": "", "/server/info ": "", "Caused by ": "", "(": "", ")": "", + ": ": "\n", "'": "", "`": "", "\"": ""} rep = {re.escape(k): v for k, v in rep.items()} pattern = re.compile("|".join(rep.keys())) - err = "" - for _ in pattern.sub(lambda m: rep[re.escape(m.group(0))], f"{status}").split("\n"): - if not _ or "urllib3" in _ or _ == "": - continue - err += _ + "\n" - return err + status = pattern.sub(lambda m: rep[re.escape(m.group(0))], f"{status}").split("\n") + return "\n".join(_ for _ in status if "urllib3" not in _ and _ != "") except TypeError or KeyError: return status