Commit 61be7b17 authored by Guillaume Seguin's avatar Guillaume Seguin

Open GCode files with rU flag to handle weird newline combinations

parent 42818bcd
...@@ -497,7 +497,7 @@ def main(): ...@@ -497,7 +497,7 @@ def main():
return return
print "Line object size:", sys.getsizeof(Line("G0 X0")) print "Line object size:", sys.getsizeof(Line("G0 X0"))
gcode = GCode(open(sys.argv[1])) gcode = GCode(open(sys.argv[1], "rU"))
print "Dimensions:" print "Dimensions:"
xdims = (gcode.xmin, gcode.xmax, gcode.width) xdims = (gcode.xmin, gcode.xmax, gcode.width)
......
...@@ -524,6 +524,6 @@ class Gviz(wx.Panel): ...@@ -524,6 +524,6 @@ class Gviz(wx.Panel):
if __name__ == '__main__': if __name__ == '__main__':
import sys import sys
app = wx.App(False) app = wx.App(False)
main = GvizWindow(open(sys.argv[1])) main = GvizWindow(open(sys.argv[1], "rU"))
main.Show() main.Show()
app.MainLoop() app.MainLoop()
...@@ -820,7 +820,7 @@ class pronsole(cmd.Cmd): ...@@ -820,7 +820,7 @@ class pronsole(cmd.Cmd):
if not os.path.exists(filename): if not os.path.exists(filename):
self.logError("File not found!") self.logError("File not found!")
return return
self.fgcode = gcoder.GCode(open(filename)) self.fgcode = gcoder.GCode(open(filename, "rU"))
self.filename = filename self.filename = filename
self.log("Loaded %s, %d lines." % (filename, len(self.fgcode))) self.log("Loaded %s, %d lines." % (filename, len(self.fgcode)))
......
...@@ -1614,7 +1614,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>.""" ...@@ -1614,7 +1614,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
fn = self.filename fn = self.filename
try: try:
self.filename = self.model_to_gcode_filename(self.filename) self.filename = self.model_to_gcode_filename(self.filename)
self.fgcode = gcoder.GCode(open(self.filename)) self.fgcode = gcoder.GCode(open(self.filename, "rU"))
if self.p.online: if self.p.online:
wx.CallAfter(self.printbtn.Enable) wx.CallAfter(self.printbtn.Enable)
...@@ -1684,7 +1684,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>.""" ...@@ -1684,7 +1684,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
self.skein(name) self.skein(name)
else: else:
self.filename = name self.filename = name
self.fgcode = gcoder.GCode(open(self.filename)) self.fgcode = gcoder.GCode(open(self.filename, "rU"))
self.statusbar.SetStatusText(_("Loaded %s, %d lines") % (name, len(self.fgcode))) self.statusbar.SetStatusText(_("Loaded %s, %d lines") % (name, len(self.fgcode)))
print _("Loaded %s, %d lines") % (name, len(self.fgcode)) print _("Loaded %s, %d lines") % (name, len(self.fgcode))
wx.CallAfter(self.printbtn.SetLabel, _("Print")) wx.CallAfter(self.printbtn.SetLabel, _("Print"))
......
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