From 63555d2c4bd204deae90262c59b73f6c663f3c79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 10 Sep 2013 23:17:34 +0200 Subject: [PATCH] Fixed SD upload (managed to break this by introducing temperature offsets). Closes #249 --- octoprint/util/comm.py | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/octoprint/util/comm.py b/octoprint/util/comm.py index bb3f9aab..db555393 100644 --- a/octoprint/util/comm.py +++ b/octoprint/util/comm.py @@ -1134,26 +1134,28 @@ class PrintingGcodeFileInformation(PrintingFileInformation): line = line[0:line.find(";")] line = line.strip() if len(line) > 0: - (tempOffset, bedTempOffset) = self._offsetCallback() - if tempOffset != 0 or bedTempOffset != 0: - tempMatch = self._tempCommandPattern.match(line) - if tempMatch is not None: - if tempMatch.group(1) == "104" or tempMatch.group(1) == "109": - offset = tempOffset - elif tempMatch.group(1) == "140" or tempMatch.group(1) == "190": - offset = bedTempOffset - else: - offset = 0 + if self._offsetCallback is not None: + (tempOffset, bedTempOffset) = self._offsetCallback() + if tempOffset != 0 or bedTempOffset != 0: + tempMatch = self._tempCommandPattern.match(line) + if tempMatch is not None: + if tempMatch.group(1) == "104" or tempMatch.group(1) == "109": + offset = tempOffset + elif tempMatch.group(1) == "140" or tempMatch.group(1) == "190": + offset = bedTempOffset + else: + offset = 0 - try: - temp = float(tempMatch.group(2)) - newTemp = temp + offset - line = line.replace("S" + tempMatch.group(2), "S%f" % newTemp) - except ValueError: - pass + try: + temp = float(tempMatch.group(2)) + newTemp = temp + offset + line = line.replace("S" + tempMatch.group(2), "S%f" % newTemp) + except ValueError: + pass return line else: return None class StreamingGcodeFileInformation(PrintingGcodeFileInformation): - pass + def __init__(self, filename): + PrintingGcodeFileInformation.__init__(self, filename, None) \ No newline at end of file