# Helpers shared by the axis and homing discovery tools
#
# Copyright (C) 2026 the Klipper contributors
#
# This file may be distributed under the terms of the GNU GPLv3 license.
def check_not_printing(printer):
vsd = printer.lookup_object('virtual_sdcard', None)
if vsd is not None and vsd.is_active():
raise printer.command_error("Command not available during a print")
def lookup_cartesian_kinematics(printer, cmd_name):
toolhead = printer.lookup_object('toolhead')
kin = toolhead.get_kinematics()
if kin.__class__.__name__ != 'CartKinematics':
raise printer.command_error(
"%s supports [cartesian] kinematics only" % (cmd_name,))
rails = getattr(kin, 'rails', None)
if rails is None or len(rails) != 3:
raise printer.command_error(
"%s is not supported with a dual carriage" % (cmd_name,))
return kin
def discard_autosave(printer, touched):
# Remove the entries set by a SAVE_CONFIG command that failed, so
# that they do not affect any later SAVE_CONFIG command
autosave = printer.lookup_object('configfile').autosave
fileconfig = autosave.fileconfig
sections = set([section for section, option in touched])
for section, option in touched:
if fileconfig.has_section(section):
fileconfig.remove_option(section, option)
if not fileconfig.options(section):
fileconfig.remove_section(section)
pending = dict(autosave.status_save_pending)
for section in sections:
if fileconfig.has_section(section):
pending[section] = {
opt: fileconfig.get(section, opt)
for opt in fileconfig.options(section)}
else:
pending.pop(section, None)
autosave.status_save_pending = pending
autosave.save_config_pending = bool(pending)
Read 6 times, last 4 days ago