From dbf3e7f0a2671630d6364b088f5c2745e311e786 Mon Sep 17 00:00:00 2001 From: Kliment Date: Thu, 11 Aug 2011 15:02:41 +0200 Subject: [PATCH] Close gcode file explicitly after reading --- pronterface.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pronterface.py b/pronterface.py index 447479a..e10e434 100755 --- a/pronterface.py +++ b/pronterface.py @@ -942,7 +942,9 @@ class PronterWindow(wx.Frame,pronsole.pronsole): fn=self.filename try: self.filename=self.filename.replace(".stl","_export.gcode").replace(".STL","_export.gcode") - self.f=[i.replace("\n","").replace("\r","") for i in open(self.filename)] + of=open(self.filename) + self.f=[i.replace("\n","").replace("\r","") for i in of] + of.close if self.p.online: wx.CallAfter(self.printbtn.Enable) @@ -992,8 +994,10 @@ class PronterWindow(wx.Frame,pronsole.pronsole): if name.lower().endswith(".stl"): self.skein(name) else: - self.f=[i.replace("\n","").replace("\r","") for i in open(name)] self.filename=name + of=open(self.filename) + self.f=[i.replace("\n","").replace("\r","") for i in of] + of.close self.status.SetStatusText("Loaded "+name+", %d lines"%(len(self.f),)) wx.CallAfter(self.printbtn.SetLabel, "Print") wx.CallAfter(self.pausebtn.SetLabel, "Pause")