Use a function to generate the "_export.xxx" filename

master
daid 2012-05-29 13:42:33 +02:00
parent 16c043e469
commit eb44963079
6 changed files with 22 additions and 16 deletions

View File

@ -18,6 +18,7 @@ from gui import projectPlanner
from gui import icon
from util import profile
from util import version
from util import sliceRun
def main():
app = wx.App(False)
@ -333,10 +334,10 @@ class mainWindow(configBase.configWindowBase):
if len(self.filelist) < 1:
wx.MessageBox('You need to load a file and slice it before you can print it.', 'Print error', wx.OK | wx.ICON_INFORMATION)
return
if not os.path.exists(self.filelist[0][: self.filelist[0].rfind('.')] + "_export.gcode"):
if not os.path.exists(sliceRun.getExportFilename(self.filelist[0])):
wx.MessageBox('You need to slice the file to GCode before you can print it.', 'Print error', wx.OK | wx.ICON_INFORMATION)
return
printWindow.printFile(self.filelist[0][: self.filelist[0].rfind('.')] + "_export.gcode")
printWindow.printFile(sliceRun.getExportFilename(self.filelist[0]))
def OnExpertOpen(self, e):
ecw = expertConfig.expertConfigWindow()

View File

@ -21,6 +21,7 @@ from util import profile
from util import gcodeInterpreter
from util import stl
from util import util3d
from util import sliceRun
class previewObject():
def __init__(self):
@ -207,8 +208,8 @@ class previewPanel(wx.Panel):
self.logFileTime = None
obj.filename = filelist[idx]
self.gcodeFilename = filelist[0][: filelist[0].rfind('.')] + "_export.gcode"
self.logFilename = filelist[0][: filelist[0].rfind('.')] + "_export.log"
self.gcodeFilename = sliceRun.getExportFilename(filelist[0])
self.logFilename = sliceRun.getExportFilename(filelist[0], "log")
#Do the STL file loading in a background thread so we don't block the UI.
if self.loadThread != None and self.loadThread.isAlive():
self.loadThread.join()

View File

@ -893,7 +893,7 @@ class ProjectSliceProgressWindow(wx.Frame):
profile.resetTempOverride()
if not action.usePreviousSlice:
f = open(action.filename[: action.filename.rfind('.')] + "_export.project_tmp", "r")
f = open(sliceRun.getExportFilename(action.filename, "project_tmp"), "r")
data = f.read(4096)
while data != '':
resultFile.write(data)
@ -902,7 +902,7 @@ class ProjectSliceProgressWindow(wx.Frame):
savedCenterX = action.centerX
savedCenterY = action.centerY
else:
f = open(action.filename[: action.filename.rfind('.')] + "_export.project_tmp", "r")
f = open(sliceRun.getExportFilename(action.filename, "project_tmp"), "r")
for line in f:
if line[0] != ';':
if 'X' in line:
@ -913,7 +913,7 @@ class ProjectSliceProgressWindow(wx.Frame):
f.close()
if not action.leaveResultForNextSlice:
os.remove(action.filename[: action.filename.rfind('.')] + "_export.project_tmp")
os.remove(sliceRun.getExportFilename(action.filename, "project_tmp"))
wx.CallAfter(self.progressGauge.SetValue, 10000)
self.totalDoneFactor = 0.0

View File

@ -14,6 +14,7 @@ from gui import printWindow
from gui import icon
from util import profile
from util import version
from util import sliceRun
class simpleModeWindow(configBase.configWindowBase):
"Main user interface window for Quickprint mode"
@ -276,10 +277,10 @@ class simpleModeWindow(configBase.configWindowBase):
if len(self.filelist) < 1:
wx.MessageBox('You need to load a file and slice it before you can print it.', 'Print error', wx.OK | wx.ICON_INFORMATION)
return
if not os.path.exists(self.filelist[0][: self.filelist[0].rfind('.')] + "_export.gcode"):
if not os.path.exists(sliceRun.getExportFilename(self.filelist[0])):
wx.MessageBox('You need to slice the file to GCode before you can print it.', 'Print error', wx.OK | wx.ICON_INFORMATION)
return
printWindow.printFile(self.filelist[0][: self.filelist[0].rfind('.')] + "_export.gcode")
printWindow.printFile(sliceRun.getExportFilename(self.filelist[0]))
def OnNormalSwitch(self, e):
from gui import mainWindow

View File

@ -68,7 +68,7 @@ class sliceProgessPanel(wx.Panel):
LogWindow('\n'.join(self.progressLog))
def OnOpenFileLocation(self, e):
exporer.openExporer(self.filelist[0][: self.filelist[0].rfind('.')] + "_export.gcode")
exporer.openExporer(sliceRun.getExportFilename(self.filelist[0]))
def OnSliceDone(self, result):
self.progressGauge.Destroy()
@ -145,7 +145,7 @@ class WorkerThread(threading.Thread):
return
line = p.stdout.readline()
self.returnCode = p.wait()
logfile = open(self.filelist[self.fileIdx][: self.filelist[self.fileIdx].rfind('.')] + "_export.log", "w")
logfile = open(sliceRun.getExportFilename(self.filelist[self.fileIdx], "log"), "w")
for logLine in self.progressLog:
logfile.write(logLine)
logfile.write('\n')
@ -155,19 +155,19 @@ class WorkerThread(threading.Thread):
if len(self.filelist) > 1:
self._stitchMultiExtruder()
self.gcode = gcodeInterpreter.gcode()
self.gcode.load(self.filelist[0][:self.filelist[0].rfind('.')]+'_export.gcode')
self.gcode.load(sliceRun.getExportFilename(self.filelist[0]))
wx.CallAfter(self.notifyWindow.OnSliceDone, self)
else:
self.run()
def _stitchMultiExtruder(self):
files = []
resultFile = open(self.filelist[0][:self.filelist[0].rfind('.')]+'_export.gcode', "w")
resultFile = open(sliceRun.getExportFilename(self.filelist[0]), "w")
resultFile.write(';TYPE:CUSTOM\n')
resultFile.write(profile.getAlterationFileContents('start.gcode'))
for filename in self.filelist:
if os.path.isfile(filename[:filename.rfind('.')]+'_export.multi_extrude_tmp'):
files.append(open(filename[:filename.rfind('.')]+'_export.multi_extrude_tmp', "r"))
if os.path.isfile(sliceRun.getExportFilename(filename, 'multi_extrude_tmp')):
files.append(open(sliceRun.getExportFilename(filename, 'multi_extrude_tmp'), "r"))
else:
return
@ -201,7 +201,7 @@ class WorkerThread(threading.Thread):
for f in files:
f.close()
for filename in self.filelist:
os.remove(filename[:filename.rfind('.')]+'_export.multi_extrude_tmp')
os.remove(sliceRun.getExportFilename(filename, 'multi_extrude_tmp'))
resultFile.write(';TYPE:CUSTOM\n')
resultFile.write(profile.getAlterationFileContents('end.gcode'))
resultFile.close()

View File

@ -83,6 +83,9 @@ def runSlice(fileNames):
else:
subprocess.call([pypyExe, os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", os.path.split(sys.argv[0])[1])), '-p', profile.getGlobalProfileString(), fileName])
def getExportFilename(filename, ext = "gcode"):
return "%s_export.%s" % (filename[: filename.rfind('.')], ext)
def getSliceCommand(filename):
if profile.getPreference('slicer').startswith('Slic3r') and getSlic3rExe() != False:
slic3rExe = getSlic3rExe()