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,6 +1121,7 @@ class pronsole(cmd.Cmd): ...@@ -1121,6 +1121,7 @@ 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):
f = None
try: try:
l = l.lower().replace(", ",".") l = l.lower().replace(", ",".")
for i in self.bedtemps.keys(): for i in self.bedtemps.keys():
...@@ -1128,9 +1129,9 @@ class pronsole(cmd.Cmd): ...@@ -1128,9 +1129,9 @@ class pronsole(cmd.Cmd):
f = float(l) f = float(l)
except: except:
self.logError(_("You must enter a temperature.")) self.logError(_("You must enter a temperature."))
if f>=0: if f is not None and f >= 0:
if self.p.online: if self.p.online:
self.p.send_now("M140 S"+l) self.p.send_now("M140 S" + l)
self.log(_("Setting bed temperature to %s degrees Celsius.") % f) self.log(_("Setting bed temperature to %s degrees Celsius.") % f)
else: else:
self.logError(_("Printer is not online.")) self.logError(_("Printer is not online."))
......
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