示例#1
0
def writeOutput(fileName=''):
    "Export a gcode linear move file."
    fileName = fabmetheus_interpret.getFirstTranslatorFileNameUnmodified(
        fileName)
    if fileName == '':
        return
    exportRepository = ExportRepository()
    settings.getReadRepository(exportRepository)
    startTime = time.time()
    print('File ' + gcodec.getSummarizedFileName(fileName) +
          ' is being chain exported.')
    Filehandle = open('report.txt', 'w')
    Filehandle.write('File ' + gcodec.getSummarizedFileName(fileName) +
                     ' is being chain exported.\n')
    Filehandle.close()
    suffixFileName = fileName[:fileName.rfind(
        '.')] + '_export.' + exportRepository.fileExtension.value
    gcodeText = gcodec.getGcodeFileText(fileName, '')
    procedures = skeinforge_craft.getProcedures('export', gcodeText)
    gcodeText = skeinforge_craft.getChainTextFromProcedures(
        fileName, procedures[:-1], gcodeText)
    if gcodeText == '':
        return
    skeinforge_analyze.writeOutput(suffixFileName, gcodeText)
    if exportRepository.savePenultimateGcode.value:
        penultimateFileName = fileName[:fileName.
                                       rfind('.')] + '_penultimate.gcode'
        gcodec.writeFileText(penultimateFileName, gcodeText)
        print('The penultimate file is saved as ' +
              gcodec.getSummarizedFileName(penultimateFileName))
    exportChainGcode = getCraftedTextFromText(gcodeText, exportRepository)
    replaceableExportChainGcode = None
    selectedPluginModule = getSelectedPluginModule(
        exportRepository.exportPlugins)
    if selectedPluginModule == None:
        replaceableExportChainGcode = exportChainGcode
    else:
        if selectedPluginModule.isReplaceable():
            replaceableExportChainGcode = selectedPluginModule.getOutput(
                exportChainGcode)
        else:
            selectedPluginModule.writeOutput(suffixFileName, exportChainGcode)
    if replaceableExportChainGcode != None:
        replaceableExportChainGcode = getReplaced(replaceableExportChainGcode)
        gcodec.writeFileText(suffixFileName, replaceableExportChainGcode)
        print('The exported file is saved as ' +
              gcodec.getSummarizedFileName(suffixFileName))
    if exportRepository.alsoSendOutputTo.value != '':
        if replaceableExportChainGcode == None:
            replaceableExportChainGcode = selectedPluginModule.getOutput(
                exportChainGcode)
        exec('print >> ' + exportRepository.alsoSendOutputTo.value +
             ', replaceableExportChainGcode')
    print('It took ' + str(int(round(time.time() - startTime))) +
          ' seconds to export the file.')
    Filehandle = open('report.txt', 'a')
    Filehandle.write('It took ' + str(int(round(time.time() - startTime))) +
                     ' seconds to export the file.')
    Filehandle.close()
示例#2
0
def writeOutput( fileName = '' ):
	"Export a gcode linear move file."
	fileName = fabmetheus_interpret.getFirstTranslatorFileNameUnmodified( fileName )
	if fileName == '':
		return
	exportRepository = ExportRepository()
	settings.getReadRepository( exportRepository )
	startTime = time.time()
	print( 'File ' + gcodec.getSummarizedFileName( fileName ) + ' is being chain exported.' )
	Filehandle = open ('report.txt', 'w')
	Filehandle.write ('File ' + gcodec.getSummarizedFileName( fileName ) + ' is being chain exported.\n')
	Filehandle.close ()
	suffixFileName = fileName[ : fileName.rfind( '.' ) ] + '_export.' + exportRepository.fileExtension.value
	gcodeText = gcodec.getGcodeFileText( fileName, '' )
	procedures = skeinforge_craft.getProcedures( 'export', gcodeText )
	gcodeText = skeinforge_craft.getChainTextFromProcedures( fileName, procedures[ : - 1 ], gcodeText )
	if gcodeText == '':
		return
	skeinforge_analyze.writeOutput( suffixFileName, gcodeText )
	if exportRepository.savePenultimateGcode.value:
		penultimateFileName = fileName[ : fileName.rfind( '.' ) ] + '_penultimate.gcode'
		gcodec.writeFileText( penultimateFileName, gcodeText )
		print( 'The penultimate file is saved as ' + gcodec.getSummarizedFileName( penultimateFileName ) )
	exportChainGcode = getCraftedTextFromText( gcodeText, exportRepository )
	replaceableExportChainGcode = None
	selectedPluginModule = getSelectedPluginModule( exportRepository.exportPlugins )
	if selectedPluginModule == None:
		replaceableExportChainGcode = exportChainGcode
	else:
		if selectedPluginModule.isReplaceable():
			replaceableExportChainGcode = selectedPluginModule.getOutput( exportChainGcode )
		else:
			selectedPluginModule.writeOutput( suffixFileName, exportChainGcode )
	if replaceableExportChainGcode != None:
		replaceableExportChainGcode = getReplaced( replaceableExportChainGcode )
		gcodec.writeFileText( suffixFileName, replaceableExportChainGcode )
		print( 'The exported file is saved as ' + gcodec.getSummarizedFileName( suffixFileName ) )
	if exportRepository.alsoSendOutputTo.value != '':
		if replaceableExportChainGcode == None:
			replaceableExportChainGcode = selectedPluginModule.getOutput( exportChainGcode )
		exec( 'print >> ' + exportRepository.alsoSendOutputTo.value + ', replaceableExportChainGcode' )
	print( 'It took ' + str( int( round( time.time() - startTime ) ) ) + ' seconds to export the file.' )
	Filehandle = open ('report.txt', 'a')
	Filehandle.write ('It took '+ str( int( round( time.time() - startTime ) ) )+' seconds to export the file.')
	Filehandle.close ()
示例#3
0
def writeChainTextWithNounMessage( fileName, procedure ):
	"Get and write a crafted shape file."
	print( '' )
	print( 'The %s tool is parsing the file:' % procedure )
	print( os.path.basename( fileName ) )
	print( '' )
	startTime = time.time()
	suffixFileName = fileName[ : fileName.rfind( '.' ) ] + '_' + procedure + '.gcode'
	craftText = getChainText( fileName, procedure )
	if craftText == '':
		return
	gcodec.writeFileText( suffixFileName, craftText )
	print( '' )
	print( 'The %s tool has created the file:' % procedure )
	print( suffixFileName )
	print( '' )
	print( 'It took %s seconds to craft the file.' % int( time.time() - startTime ) )
	skeinforge_analyze.writeOutput( suffixFileName, craftText )