From 9675968b27318c791be995248a34a47948f22e1d Mon Sep 17 00:00:00 2001 From: daid303 Date: Mon, 1 Oct 2012 18:15:51 +0200 Subject: [PATCH] Fix support for slicing if running from pythonw.exe --- Cura/gui/batchRun.py | 2 +- Cura/gui/printWindow.py | 2 +- Cura/gui/projectPlanner.py | 2 +- Cura/gui/sliceProgessPanel.py | 9 +-------- Cura/util/sliceRun.py | 8 ++++++++ 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Cura/gui/batchRun.py b/Cura/gui/batchRun.py index 9762d6a..295d321 100644 --- a/Cura/gui/batchRun.py +++ b/Cura/gui/batchRun.py @@ -187,7 +187,7 @@ class BatchSliceProgressWindow(wx.Frame): self.cmdIndex += 1 wx.CallAfter(self.SetTitle, "Building: [%d/%d]" % (self.sliceCmdList.index(action) + 1, len(self.sliceCmdList))) - p = subprocess.Popen(action, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + p = sliceRun.startSliceCommandProcess(action) line = p.stdout.readline() maxValue = 1 while(len(line) > 0): diff --git a/Cura/gui/printWindow.py b/Cura/gui/printWindow.py index 1bca20a..83642b1 100644 --- a/Cura/gui/printWindow.py +++ b/Cura/gui/printWindow.py @@ -38,7 +38,7 @@ class printProcessMonitor(): def loadFile(self, filename): if self.handle == None: - self.handle = subprocess.Popen([sys.executable, sys.argv[0], '-r', filename], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + self.handle = subprocess.Popen([sys.executable, sys.argv[0], '-r', filename], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) self.thread = threading.Thread(target=self.Monitor) self.thread.start() else: diff --git a/Cura/gui/projectPlanner.py b/Cura/gui/projectPlanner.py index c521ca5..b965265 100644 --- a/Cura/gui/projectPlanner.py +++ b/Cura/gui/projectPlanner.py @@ -939,7 +939,7 @@ class ProjectSliceProgressWindow(wx.Frame): for action in self.actionList: wx.CallAfter(self.SetTitle, "Building: [%d/%d]" % (self.actionList.index(action) + 1, len(self.actionList))) if not action.usePreviousSlice: - p = subprocess.Popen(action.sliceCmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + p = sliceRun.startSliceCommandProcess(action.sliceCmd) line = p.stdout.readline() maxValue = 1 diff --git a/Cura/gui/sliceProgessPanel.py b/Cura/gui/sliceProgessPanel.py index bd278cc..9cc6843 100644 --- a/Cura/gui/sliceProgessPanel.py +++ b/Cura/gui/sliceProgessPanel.py @@ -135,14 +135,7 @@ class WorkerThread(threading.Thread): self.start() def run(self): - kwargs = {} - if subprocess.mswindows: - su = subprocess.STARTUPINFO() - su.dwFlags |= subprocess.STARTF_USESHOWWINDOW - su.wShowWindow = subprocess.SW_HIDE - kwargs['startupinfo'] = su - print self.cmdList[self.fileIdx] - p = subprocess.Popen(self.cmdList[self.fileIdx], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs) + p = sliceRun.startSliceCommandProcess(self.cmdList[self.fileIdx]) line = p.stdout.readline() self.progressLog = [] maxValue = 1 diff --git a/Cura/util/sliceRun.py b/Cura/util/sliceRun.py index 824aa1e..c4b6bf7 100644 --- a/Cura/util/sliceRun.py +++ b/Cura/util/sliceRun.py @@ -178,3 +178,11 @@ def getSliceCommand(filename): cmd.append(filename) return cmd +def startSliceCommandProcess(cmdList): + kwargs = {} + if subprocess.mswindows: + su = subprocess.STARTUPINFO() + su.dwFlags |= subprocess.STARTF_USESHOWWINDOW + su.wShowWindow = subprocess.SW_HIDE + kwargs['startupinfo'] = su + p = subprocess.Popen(cmdList, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs)