修复耗材检测弹窗异常问题

This commit is contained in:
张开科 2025-01-03 15:00:54 +08:00
parent 3bfc1aa714
commit 413bf6fc4a
2 changed files with 5 additions and 5 deletions

View File

@ -23,14 +23,14 @@ class Prompt:
def decode(self, data):
logging.info(f'{data}')
if data.startswith('prompt_begin'):
self.header = _(data.replace('prompt_begin', '').lstrip())
self.header = _(cleaned_data) if (cleaned_data := data.replace("prompt_begin", "").strip()) else ""
if self.header:
self.window_title = self.header
self.text = ""
self.buttons = []
return
elif data.startswith('prompt_text'):
self.text = _(data.replace('prompt_text ', '').lstrip())
self.text = _(cleaned_data) if (cleaned_data := data.replace("prompt_text", "").strip()) else ""
return
elif data.startswith('prompt_button ') or data.startswith('prompt_footer_button'):
data = data.replace('prompt_button ', '')

View File

@ -876,7 +876,7 @@ class KlipperScreen(Gtk.Window):
elif action == "notify_update_response":
if 'message' in data and 'Error' in data['message']:
logging.error(f"{action}:{data['message']}")
self.show_popup_message(_(data['message'].lstrip()), 3, from_ws=True)
self.show_popup_message(_(cleaned_data) if (cleaned_data := data['message'].strip()) else "", 3, from_ws=True)
if "KlipperScreen" in data['message']:
self.restart_ks()
elif action == "notify_power_changed":
@ -895,9 +895,9 @@ class KlipperScreen(Gtk.Window):
return
self.prompt.decode(action)
elif data.startswith("echo: "):
self.show_popup_message(_(data[6:].lstrip()), 1, from_ws=True)
self.show_popup_message(_(cleaned_data) if (cleaned_data := data[6:].strip()) else "", 1, from_ws=True)
elif data.startswith("!! "):
self.show_popup_message(_(data[3:].lstrip()), 3, from_ws=True)
self.show_popup_message(_(cleaned_data) if (cleaned_data := data[3:].strip()) else "", 3, from_ws=True)
elif "unknown" in data.lower() and \
not ("TESTZ" in data or "MEASURE_AXES_NOISE" in data or "ACCELEROMETER_QUERY" in data):
self.show_popup_message(data, from_ws=True)