aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/klippy.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2022-05-06 21:06:13 -0400
committerKevin O'Connor <kevin@koconnor.net>2022-05-06 21:06:13 -0400
commit7e76bd561a451172f8d03001445a3bd21e3866d7 (patch)
treece8c8ea5ebc5bd0d49a4e418e1370c21118d3b22 /klippy/klippy.py
parentb18786bc9199fdb31c45701962400325e3814e42 (diff)
downloadkutter-7e76bd561a451172f8d03001445a3bd21e3866d7.tar.gz
kutter-7e76bd561a451172f8d03001445a3bd21e3866d7.tar.xz
kutter-7e76bd561a451172f8d03001445a3bd21e3866d7.zip
klippy: Minor changes to message protocol error
Minor indentation and variable name changes. Don't remove linebreaks from message_protocol_error lines. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/klippy.py')
-rw-r--r--klippy/klippy.py51
1 files changed, 18 insertions, 33 deletions
diff --git a/klippy/klippy.py b/klippy/klippy.py
index 9692e605..d7b62453 100644
--- a/klippy/klippy.py
+++ b/klippy/klippy.py
@@ -22,15 +22,13 @@ command to reload the config and restart the host software.
Printer is halted
"""
-message_protocol_error1 = "MCU Protocol error"
-
-message_protocol_error2 = """
+message_protocol_error1 = """
This is frequently caused by running an older version of the
firmware on the MCU(s). Fix by recompiling and flashing the
firmware.
"""
-message_protocol_error3 = """
+message_protocol_error2 = """
Once the underlying issue is corrected, use the "RESTART"
command to reload the config and restart the host software.
"""
@@ -145,46 +143,33 @@ class Printer:
m.add_printer_objects(config)
# Validate that there are no undefined parameters in the config file
pconfig.check_unused_options(config)
-
def _build_protocol_error_message(self, e):
host_version = self.start_args['software_version']
-
msg_update = []
msg_updated = []
-
- for n,mcu_obj in self.lookup_objects('mcu'):
+ for mcu_name, mcu in self.lookup_objects('mcu'):
try:
- mcu_version = mcu_obj.get_status()['mcu_version']
+ mcu_version = mcu.get_status()['mcu_version']
except:
- logging.exception("Unable to retrieve mcu_version from mcu_obj")
+ logging.exception("Unable to retrieve mcu_version from mcu")
continue
-
if mcu_version != host_version:
- msg_update.append("%s: Current version %s" % (
- n.split()[-1], mcu_obj.get_status()['mcu_version']))
+ msg_update.append("%s: Current version %s"
+ % (mcu_name.split()[-1], mcu_version))
else:
- msg_updated.append("%s: Current version %s" % (
- n.split()[-1], mcu_obj.get_status()['mcu_version']))
-
- if len(msg_updated) == 0:
+ msg_updated.append("%s: Current version %s"
+ % (mcu_name.split()[-1], mcu_version))
+ if not msg_update:
+ msg_update.append("<none>")
+ if not msg_updated:
msg_updated.append("<none>")
-
- version_msg = ["\nYour Klipper version is: %s\n" % host_version,
- "MCU(s) which should be updated:",
- "\n%s\n" % "\n".join(msg_update),
- "Up-to-date MCU(s):",
- "\n%s\n" % "\n".join(msg_updated)]
-
- msg = [message_protocol_error1,
- "",
- ' '.join(message_protocol_error2.splitlines())[1:],
- "\n".join(version_msg),
- ' '.join(message_protocol_error3.splitlines())[1:],
- "",
- str(e)]
-
+ msg = ["MCU Protocol error",
+ message_protocol_error1,
+ "Your Klipper version is: %s" % (host_version,),
+ "MCU(s) which should be updated:"]
+ msg += msg_update + ["Up-to-date MCU(s):"] + msg_updated
+ msg += [message_protocol_error2, str(e)]
return "\n".join(msg)
-
def _connect(self, eventtime):
try:
self._read_config()