From 30e43f9c416b3994905337e11bb8cb171430bf71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Sun, 1 Feb 2015 17:27:12 +0100 Subject: [PATCH] Fixed a bug causing gcodeInterpreter to hiccup on GCODES containing invalid coordinates such as Xnan or Yinf, causing in turn the file API to fail until the offending file was deleted and its metadata removed (cherry picked from commit ce363ce) --- src/octoprint/util/gcodeInterpreter.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/octoprint/util/gcodeInterpreter.py b/src/octoprint/util/gcodeInterpreter.py index b901a12f..9c3d05ae 100644 --- a/src/octoprint/util/gcodeInterpreter.py +++ b/src/octoprint/util/gcodeInterpreter.py @@ -249,13 +249,16 @@ def getCodeInt(line, code): def getCodeFloat(line, code): + import math n = line.find(code) + 1 if n < 1: return None m = line.find(' ', n) try: if m < 0: - return float(line[n:]) - return float(line[n:m]) + val = float(line[n:]) + else: + val = float(line[n:m]) + return val if not (math.isnan(val) or math.isinf(val)) else None except: return None