mirror of
https://github.com/QIDITECH/klipper.git
synced 2026-01-30 23:48:43 +03:00
repair missing update
This commit is contained in:
@@ -18,6 +18,29 @@ class SaveVariables:
|
||||
gcode = self.printer.lookup_object('gcode')
|
||||
gcode.register_command('SAVE_VARIABLE', self.cmd_SAVE_VARIABLE,
|
||||
desc=self.cmd_SAVE_VARIABLE_help)
|
||||
|
||||
def load_variable(self, section, option):
|
||||
varfile = configparser.ConfigParser()
|
||||
try:
|
||||
varfile.read(self.filename)
|
||||
return varfile.get(section, option)
|
||||
except:
|
||||
msg = "Unable to parse existing variable file"
|
||||
logging.exception(msg)
|
||||
raise self.printer.command_error(msg)
|
||||
def save_variable(self, section, option, value):
|
||||
varfile = configparser.ConfigParser()
|
||||
try:
|
||||
varfile.read(self.filename)
|
||||
if not varfile.has_section(section):
|
||||
varfile.add_section(section)
|
||||
varfile.set(section, option, value)
|
||||
with open(self.filename, 'w') as configfile:
|
||||
varfile.write(configfile)
|
||||
except Exception as e:
|
||||
msg = "Unable to save variable"
|
||||
logging.exception(msg)
|
||||
raise self.printer.command_error(msg)
|
||||
def loadVariables(self):
|
||||
allvars = {}
|
||||
varfile = configparser.ConfigParser()
|
||||
|
||||
Reference in New Issue
Block a user