+from __future__ import absolute_import
+import __init__
+
import sys
import math
import threading
class gcode():
def __init__(self, filename):
+ self.regMatch = {}
+
fileSize = os.stat(filename).st_size
filePos = 0
gcodeFile = open(filename, 'r')
print "Extruded a total of: %d mm of filament" % (self.extrusionAmount)
print "Estimated print duration: %.2f minutes" % (self.totalMoveTimeMinute)
- def getCodeInt(self, str, id):
- m = re.search(id + '([^\s]+)', str)
+ def getCodeInt(self, line, code):
+ if code not in self.regMatch:
+ self.regMatch[code] = re.compile(code + '([^\s]+)')
+ m = self.regMatch[code].search(line)
if m == None:
return None
try:
except:
return None
- def getCodeFloat(self, str, id):
- m = re.search(id + '([^\s]+)', str)
+ def getCodeFloat(self, line, code):
+ if code not in self.regMatch:
+ self.regMatch[code] = re.compile(code + '([^\s]+)')
+ m = self.regMatch[code].search(line)
if m == None:
return None
try:
except:
return None
+if __name__ == '__main__':
+ for filename in sys.argv[1:]:
+ gcode(filename)
+