gcode_macro: Use new GCodeCommand wrappers
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
fb16e8810b
commit
a13e681b2e
|
@ -138,20 +138,18 @@ class GCodeMacro:
|
|||
def get_status(self, eventtime):
|
||||
return dict(self.variables)
|
||||
cmd_SET_GCODE_VARIABLE_help = "Set the value of a G-Code macro variable"
|
||||
def cmd_SET_GCODE_VARIABLE(self, params):
|
||||
variable = self.gcode.get_str('VARIABLE', params)
|
||||
value = self.gcode.get_str('VALUE', params)
|
||||
def cmd_SET_GCODE_VARIABLE(self, gcmd):
|
||||
variable = gcmd.get('VARIABLE')
|
||||
value = gcmd.get('VALUE')
|
||||
if variable not in self.variables:
|
||||
if variable in self.kwparams:
|
||||
self.kwparams[variable] = value
|
||||
return
|
||||
raise self.gcode.error("Unknown gcode_macro variable '%s'" % (
|
||||
variable,))
|
||||
raise gcmd.error("Unknown gcode_macro variable '%s'" % (variable,))
|
||||
try:
|
||||
literal = ast.literal_eval(value)
|
||||
except ValueError as e:
|
||||
raise self.gcode.error("Unable to parse '%s' as a literal" % (
|
||||
value,))
|
||||
raise gcmd.error("Unable to parse '%s' as a literal" % (value,))
|
||||
self.variables[variable] = literal
|
||||
cmd_desc = "G-Code macro"
|
||||
def cmd(self, gcmd):
|
||||
|
|
Loading…
Reference in New Issue