gcode: Allow rename_existing also for register_mux_command (#4843)

Signed-off-by: Alex Zellner <alexander.zellner@googlemail.com>
This commit is contained in:
Alex Zellner 2021-11-22 17:22:12 +01:00 committed by GitHub
parent 7085ed2d6c
commit 05a8aca0a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -142,7 +142,8 @@ class GCodeDispatch:
def register_mux_command(self, cmd, key, value, func, desc=None): def register_mux_command(self, cmd, key, value, func, desc=None):
prev = self.mux_commands.get(cmd) prev = self.mux_commands.get(cmd)
if prev is None: if prev is None:
self.register_command(cmd, self._cmd_mux, desc=desc) handler = lambda gcmd: self._cmd_mux(cmd, gcmd)
self.register_command(cmd, handler, desc=desc)
self.mux_commands[cmd] = prev = (key, {}) self.mux_commands[cmd] = prev = (key, {})
prev_key, prev_values = prev prev_key, prev_values = prev
if prev_key != key: if prev_key != key:
@ -290,8 +291,8 @@ class GCodeDispatch:
# Don't warn about requests to turn off fan when fan not present # Don't warn about requests to turn off fan when fan not present
return return
gcmd.respond_info('Unknown command:"%s"' % (cmd,)) gcmd.respond_info('Unknown command:"%s"' % (cmd,))
def _cmd_mux(self, gcmd): def _cmd_mux(self, command, gcmd):
key, values = self.mux_commands[gcmd.get_command()] key, values = self.mux_commands[command]
if None in values: if None in values:
key_param = gcmd.get(key, None) key_param = gcmd.get(key, None)
else: else: