Commit d1cc9e28 authored by Guillaume Seguin's avatar Guillaume Seguin

Reindent do_bedtemp and fix broken code path

The if f >= 0 could be have been accessed even though f had not been
assigned (if float(l) failed)
parent 2aecf651
...@@ -1121,21 +1121,22 @@ class pronsole(cmd.Cmd): ...@@ -1121,21 +1121,22 @@ class pronsole(cmd.Cmd):
return [i for i in self.temps.keys() if i.startswith(text)] return [i for i in self.temps.keys() if i.startswith(text)]
def do_bedtemp(self, l): def do_bedtemp(self, l):
try: f = None
l = l.lower().replace(", ",".") try:
for i in self.bedtemps.keys(): l = l.lower().replace(", ",".")
l = l.replace(i, self.bedtemps[i]) for i in self.bedtemps.keys():
f = float(l) l = l.replace(i, self.bedtemps[i])
except: f = float(l)
self.logError(_("You must enter a temperature.")) except:
if f>=0: self.logError(_("You must enter a temperature."))
if self.p.online: if f is not None and f >= 0:
self.p.send_now("M140 S"+l) if self.p.online:
self.log(_("Setting bed temperature to %s degrees Celsius.") % f) self.p.send_now("M140 S" + l)
else: self.log(_("Setting bed temperature to %s degrees Celsius.") % f)
self.logError(_("Printer is not online."))
else: else:
self.logError(_("You cannot set negative temperatures. To turn the bed off entirely, set its temperature to 0.")) self.logError(_("Printer is not online."))
else:
self.logError(_("You cannot set negative temperatures. To turn the bed off entirely, set its temperature to 0."))
def help_bedtemp(self): def help_bedtemp(self):
self.log(_("Sets the bed temperature to the value entered.")) self.log(_("Sets the bed temperature to the value entered."))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment