Exemplo n.º 1
0
def getOutput(fileName):
	'Export a gcode linear move file.'
	if fileName == '':
		return None
	repository = ExportRepository()
	settings.getReadRepository(repository)
	startTime = time.time()
	print('File ' + archive.getSummarizedFileName(fileName.encode('ascii', 'replace')) + ' is being chain exported.')
	gcodeText = gcodec.getGcodeFileText(fileName, '')
	procedures = skeinforge_craft.getProcedures('export', gcodeText)
	gcodeText = skeinforge_craft.getChainTextFromProcedures(fileName, procedures[: -1], gcodeText)
	if gcodeText == '':
		return None
	fileNamePenultimate = fileName[: fileName.rfind('.')] + '_penultimate.gcode'
	if repository.savePenultimateGcode.value:
		archive.writeFileText(fileNamePenultimate, gcodeText)
		print('The penultimate file is saved as ' + archive.getSummarizedFileName(fileNamePenultimate))
	exportGcode = getCraftedTextFromText(gcodeText, repository)
	replaceableExportGcode = None
	selectedPluginModule = getSelectedPluginModule(repository.exportPlugins)
	if selectedPluginModule is None:
		replaceableExportGcode = exportGcode
	else:
		if selectedPluginModule.globalIsReplaceable:
			replaceableExportGcode = selectedPluginModule.getOutput(exportGcode)
		#else:
		#	selectedPluginModule.writeOutput(outputFilename, exportGcode)
	if replaceableExportGcode is not None:
		replaceableExportGcode = getReplaceableExportGcode(repository.nameOfReplaceFile.value, replaceableExportGcode)
	if repository.alsoSendOutputTo.value != '':
		if replaceableExportGcode == None:
			replaceableExportGcode = selectedPluginModule.getOutput(exportGcode)
		sendOutputTo(repository.alsoSendOutputTo.value, replaceableExportGcode)
	print('It took %s to export the file.' % euclidean.getDurationString(time.time() - startTime))
	return replaceableExportGcode
Exemplo n.º 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()
def writeOutput( fileName, gcodeText = ''):
	"Write the exported version of a gcode file."
	gcodeText = gcodec.getGcodeFileText(fileName, gcodeText)
	repository = GcodeTimeSegmentRepository()
	settings.getReadRepository(repository)
	output = getOutput(gcodeText, repository)
	suffixFileName = fileName[ : fileName.rfind('.') ] + '_gcode_time_segment.gcode'
	archive.writeFileText( suffixFileName, output )
	print('The converted file is saved as ' + archive.getSummarizedFileName(suffixFileName) )
Exemplo n.º 4
0
def writeOutput( fileName, gcodeText = ''):
	"Write the exported version of a gcode file."
	binary16ByteRepository = Binary16ByteRepository()
	settings.getReadRepository( binary16ByteRepository )
	gcodeText = gcodec.getGcodeFileText(fileName, gcodeText)
	skeinOutput = getOutput( gcodeText, binary16ByteRepository )
	suffixFileName = fileName[ : fileName.rfind('.') ] + '.' + binary16ByteRepository.fileExtension.value
	archive.writeFileText( suffixFileName, skeinOutput )
	print('The converted file is saved as ' + archive.getSummarizedFileName(suffixFileName) )
Exemplo n.º 5
0
def writeOutput( fileName, gcodeText = ''):
	"Write the exported version of a gcode file."
	gcodeText = gcodec.getGcodeFileText(fileName, gcodeText)
	repository = GcodeTimeSegmentRepository()
	settings.getReadRepository(repository)
	output = getOutput(gcodeText, repository)
	suffixFileName = fileName[ : fileName.rfind('.') ] + '_gcode_time_segment.gcode'
	archive.writeFileText( suffixFileName, output )
	print('The converted file is saved as ' + archive.getSummarizedFileName(suffixFileName) )
Exemplo n.º 6
0
def writeOutput(fileName, shouldAnalyze=True):
    "Export a gcode linear move file."
    if fileName == "":
        return None
    repository = ExportRepository()
    settings.getReadRepository(repository)
    startTime = time.time()
    print("File " + archive.getSummarizedFileName(fileName) + " is being chain exported.")
    fileNameSuffix = fileName[: fileName.rfind(".")]
    if repository.addExportSuffix.value:
        fileNameSuffix += "_export"
    gcodeText = gcodec.getGcodeFileText(fileName, "")

    if repository.addProfileExtension.value:
        profileName = skeinforge_profile.getProfileName(skeinforge_profile.getCraftTypeName())
        if profileName:
            fileNameSuffix += "." + string.replace(profileName, " ", "_")
    if repository.addDescriptiveExtension.value:
        fileNameSuffix += getDescriptiveExtension(gcodeText)
    if repository.addTimestampExtension.value:
        fileNameSuffix += "." + getFirstValue(gcodeText, "(<timeStampPreface>")
    fileNameSuffix += "." + repository.fileExtension.value
    procedures = skeinforge_craft.getProcedures("export", gcodeText)
    gcodeText = skeinforge_craft.getChainTextFromProcedures(fileName, procedures[:-1], gcodeText)
    if gcodeText == "":
        return None
    fileNamePenultimate = fileName[: fileName.rfind(".")] + "_penultimate.gcode"
    filePenultimateWritten = False
    if repository.savePenultimateGcode.value:
        archive.writeFileText(fileNamePenultimate, gcodeText)
        filePenultimateWritten = True
        print("The penultimate file is saved as " + archive.getSummarizedFileName(fileNamePenultimate))
    exportGcode = getCraftedTextFromText(gcodeText, repository)
    window = None
    if shouldAnalyze:
        window = skeinforge_analyze.writeOutput(
            fileName, fileNamePenultimate, fileNameSuffix, filePenultimateWritten, gcodeText
        )
    replaceableExportGcode = None
    selectedPluginModule = getSelectedPluginModule(repository.exportPlugins)
    if selectedPluginModule == None:
        replaceableExportGcode = exportGcode
    else:
        if selectedPluginModule.globalIsReplaceable:
            replaceableExportGcode = selectedPluginModule.getOutput(exportGcode)
        else:
            selectedPluginModule.writeOutput(fileNameSuffix, exportGcode)
    if replaceableExportGcode != None:
        replaceableExportGcode = getReplaceableExportGcode(repository.nameOfReplaceFile.value, replaceableExportGcode)
        archive.writeFileText(fileNameSuffix, replaceableExportGcode)
        print("The exported file is saved as " + archive.getSummarizedFileName(fileNameSuffix))
    if repository.alsoSendOutputTo.value != "":
        if replaceableExportGcode == None:
            replaceableExportGcode = selectedPluginModule.getOutput(exportGcode)
        sendOutputTo(repository.alsoSendOutputTo.value, replaceableExportGcode)
    print("It took %s to export the file." % euclidean.getDurationString(time.time() - startTime))
    return window
Exemplo n.º 7
0
def writeOutput(fileName, shouldAnalyze=True):
    'Export a gcode linear move file.'
    if fileName == '':
        return None
    repository = ExportRepository()
    settings.getReadRepository(repository)
    startTime = time.time()
    print('File ' + archive.getSummarizedFileName(fileName) +
          ' is being chain exported.')
    fileNameSuffix = fileName[:fileName.rfind('.')]
    if repository.addExportSuffix.value:
        fileNameSuffix += '_export'
    fileNameSuffix += '.' + repository.fileExtension.value
    gcodeText = gcodec.getGcodeFileText(fileName, '')
    procedures = skeinforge_craft.getProcedures('export', gcodeText)
    gcodeText = skeinforge_craft.getChainTextFromProcedures(
        fileName, procedures[:-1], gcodeText)
    if gcodeText == '':
        return None
    if repository.savePenultimateGcode.value:
        penultimateFileName = fileName[:fileName.
                                       rfind('.')] + '_penultimate.gcode'
        archive.writeFileText(penultimateFileName, gcodeText)
        print('The penultimate file is saved as ' +
              archive.getSummarizedFileName(penultimateFileName))
    exportGcode = getCraftedTextFromText(gcodeText, repository)
    window = None
    if shouldAnalyze:
        window = skeinforge_analyze.writeOutput(fileName, fileNameSuffix,
                                                gcodeText)
    replaceableExportGcode = None
    selectedPluginModule = getSelectedPluginModule(repository.exportPlugins)
    if selectedPluginModule == None:
        replaceableExportGcode = exportGcode
    else:
        if selectedPluginModule.globalIsReplaceable:
            replaceableExportGcode = selectedPluginModule.getOutput(
                exportGcode)
        else:
            selectedPluginModule.writeOutput(fileNameSuffix, exportGcode)
    if replaceableExportGcode != None:
        replaceableExportGcode = getReplaceableExportGcode(
            repository.nameOfReplaceFile.value, replaceableExportGcode)
        archive.writeFileText(fileNameSuffix, replaceableExportGcode)
        print('The exported file is saved as ' +
              archive.getSummarizedFileName(fileNameSuffix))
    if repository.alsoSendOutputTo.value != '':
        if replaceableExportGcode == None:
            replaceableExportGcode = selectedPluginModule.getOutput(
                exportGcode)
        sendOutputTo(replaceableExportGcode, repository.alsoSendOutputTo.value)
    print('It took %s to export the file.' %
          euclidean.getDurationString(time.time() - startTime))
    return window
Exemplo n.º 8
0
def writeOutput(fileName=''):
    'Export a gcode linear move file.'
    fileName = fabmetheus_interpret.getFirstTranslatorFileNameUnmodified(
        fileName)
    if fileName == '':
        return
    repository = ExportRepository()
    settings.getReadRepository(repository)
    startTime = time.time()
    print('File ' + archive.getSummarizedFileName(fileName) +
          ' is being chain exported.')
    suffixFileName = fileName[:fileName.rfind('.')]
    if repository.addExportSuffix.value:
        suffixFileName += '_export'
    suffixFileName += '.' + repository.fileExtension.value
    gcodeText = gcodec.getGcodeFileText(fileName, '')
    procedures = skeinforge_craft.getProcedures('export', gcodeText)
    gcodeText = skeinforge_craft.getChainTextFromProcedures(
        fileName, procedures[:-1], gcodeText)
    if gcodeText == '':
        return
    window = skeinforge_analyze.writeOutput(fileName, suffixFileName,
                                            gcodeText)
    if repository.savePenultimateGcode.value:
        penultimateFileName = fileName[:fileName.
                                       rfind('.')] + '_penultimate.gcode'
        archive.writeFileText(penultimateFileName, gcodeText)
        print('The penultimate file is saved as ' +
              archive.getSummarizedFileName(penultimateFileName))
    exportChainGcode = getCraftedTextFromText(gcodeText, repository)
    replaceableExportChainGcode = None
    selectedPluginModule = getSelectedPluginModule(repository.exportPlugins)
    if selectedPluginModule == None:
        replaceableExportChainGcode = exportChainGcode
    else:
        if selectedPluginModule.globalIsReplaceable:
            replaceableExportChainGcode = selectedPluginModule.getOutput(
                exportChainGcode)
        else:
            selectedPluginModule.writeOutput(suffixFileName, exportChainGcode)
    if replaceableExportChainGcode != None:
        replaceableExportChainGcode = getReplaced(replaceableExportChainGcode)
        archive.writeFileText(suffixFileName, replaceableExportChainGcode)
        print('The exported file is saved as ' +
              archive.getSummarizedFileName(suffixFileName))
    if repository.alsoSendOutputTo.value != '':
        if replaceableExportChainGcode == None:
            replaceableExportChainGcode = selectedPluginModule.getOutput(
                exportChainGcode)
        exec('print >> ' + repository.alsoSendOutputTo.value +
             ', replaceableExportChainGcode')
    print('It took %s to export the file.' %
          euclidean.getDurationString(time.time() - startTime))
    return window
Exemplo n.º 9
0
def writeOutput(fileName, shouldAnalyze=True):
	'Export a gcode linear move file.'
	if fileName == '':
		return None
	repository = ExportRepository()
	settings.getReadRepository(repository)
	startTime = time.time()
	print('File ' + archive.getSummarizedFileName(fileName) + ' is being chain exported.')
	fileNameSuffix = fileName[: fileName.rfind('.')]
	if repository.addExportSuffix.value:
		fileNameSuffix += '_export'
	gcodeText = gcodec.getGcodeFileText(fileName, '')
	procedures = skeinforge_craft.getProcedures('export', gcodeText)
	gcodeText = skeinforge_craft.getChainTextFromProcedures(fileName, procedures[: -1], gcodeText)
	if gcodeText == '':
		return None
	if repository.addProfileExtension.value:
		fileNameSuffix += '.' + getFirstValue(gcodeText, '(<profileName>')
	if repository.addDescriptiveExtension.value:
		print(  'getDescriptiveExtension(gcodeText)')
		print(  getDescriptiveExtension(gcodeText))
		fileNameSuffix += getDescriptiveExtension(gcodeText)
	if repository.addTimestampExtension.value:
		fileNameSuffix += '.' + getFirstValue(gcodeText, '(<timeStampPreface>')
	fileNameSuffix += '.' + repository.fileExtension.value
	fileNamePenultimate = fileName[: fileName.rfind('.')] + '_penultimate.gcode'
	filePenultimateWritten = False
	if repository.savePenultimateGcode.value:
		archive.writeFileText(fileNamePenultimate, gcodeText)
		filePenultimateWritten = True
		print('The penultimate file is saved as ' + archive.getSummarizedFileName(fileNamePenultimate))
	exportGcode = getCraftedTextFromText(gcodeText, repository)
	window = None
	if shouldAnalyze and repository.analyzeGcode.value:
		window = skeinforge_analyze.writeOutput(fileName, fileNamePenultimate, fileNameSuffix, filePenultimateWritten, gcodeText)
	replaceableExportGcode = None
	selectedPluginModule = getSelectedPluginModule(repository.exportPlugins)
	if selectedPluginModule == None:
		replaceableExportGcode = exportGcode
	else:
		if selectedPluginModule.globalIsReplaceable:
			replaceableExportGcode = selectedPluginModule.getOutput(exportGcode)
		else:
			selectedPluginModule.writeOutput(fileNameSuffix, exportGcode)
	if replaceableExportGcode != None:
		replaceableExportGcode = getReplaceableExportGcode(repository.nameOfReplaceFile.value, replaceableExportGcode)
		archive.writeFileText( fileNameSuffix, replaceableExportGcode )
		print('The exported file is saved as ' + archive.getSummarizedFileName(fileNameSuffix))
	if repository.alsoSendOutputTo.value != '':
		if replaceableExportGcode == None:
			replaceableExportGcode = selectedPluginModule.getOutput(exportGcode)
		sendOutputTo(repository.alsoSendOutputTo.value, replaceableExportGcode)
	print('It took %s to export the file.' % euclidean.getDurationString(time.time() - startTime))
	return window
Exemplo n.º 10
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 ()
Exemplo n.º 11
0
def getOutput(fileName):
    'Export a gcode linear move file.'
    if fileName == '':
        return None
    repository = ExportRepository()
    settings.getReadRepository(repository)
    startTime = time.time()
    print('File ' +
          archive.getSummarizedFileName(fileName.encode('ascii', 'replace')) +
          ' is being chain exported.')
    gcodeText = gcodec.getGcodeFileText(fileName, '')
    procedures = skeinforge_craft.getProcedures('export', gcodeText)
    gcodeText = skeinforge_craft.getChainTextFromProcedures(
        fileName, procedures[:-1], gcodeText)
    if gcodeText == '':
        return None
    fileNamePenultimate = fileName[:fileName.rfind('.')] + '_penultimate.gcode'
    if repository.savePenultimateGcode.value:
        archive.writeFileText(fileNamePenultimate, gcodeText)
        print('The penultimate file is saved as ' +
              archive.getSummarizedFileName(fileNamePenultimate))
    exportGcode = getCraftedTextFromText(gcodeText, repository)
    replaceableExportGcode = None
    selectedPluginModule = getSelectedPluginModule(repository.exportPlugins)
    if selectedPluginModule is None:
        replaceableExportGcode = exportGcode
    else:
        if selectedPluginModule.globalIsReplaceable:
            replaceableExportGcode = selectedPluginModule.getOutput(
                exportGcode)
        #else:
        #	selectedPluginModule.writeOutput(outputFilename, exportGcode)
    if replaceableExportGcode is not None:
        replaceableExportGcode = getReplaceableExportGcode(
            repository.nameOfReplaceFile.value, replaceableExportGcode)
    if repository.alsoSendOutputTo.value != '':
        if replaceableExportGcode == None:
            replaceableExportGcode = selectedPluginModule.getOutput(
                exportGcode)
        sendOutputTo(repository.alsoSendOutputTo.value, replaceableExportGcode)
    print('It took %s to export the file.' %
          euclidean.getDurationString(time.time() - startTime))
    return replaceableExportGcode
Exemplo n.º 12
0
def writeOutput(fileName=''):
	'Export a gcode linear move file.'
	fileName = fabmetheus_interpret.getFirstTranslatorFileNameUnmodified(fileName)
	if fileName == '':
		return
	repository = ExportRepository()
	settings.getReadRepository(repository)
	startTime = time.time()
	print('File ' + archive.getSummarizedFileName(fileName) + ' is being chain exported.')
	suffixFileName = fileName[: fileName.rfind('.')]
	if repository.addExportSuffix.value:
		suffixFileName += '_export'
	suffixFileName += '.' + repository.fileExtension.value
	gcodeText = gcodec.getGcodeFileText(fileName, '')
	procedures = skeinforge_craft.getProcedures('export', gcodeText)
	gcodeText = skeinforge_craft.getChainTextFromProcedures(fileName, procedures[ : - 1 ], gcodeText)
	if gcodeText == '':
		return
	window = skeinforge_analyze.writeOutput(fileName, suffixFileName, gcodeText)
	if repository.savePenultimateGcode.value:
		penultimateFileName = fileName[: fileName.rfind('.')] + '_penultimate.gcode'
		archive.writeFileText(penultimateFileName, gcodeText)
		print('The penultimate file is saved as ' + archive.getSummarizedFileName(penultimateFileName))
	exportChainGcode = getCraftedTextFromText(gcodeText, repository)
	replaceableExportChainGcode = None
	selectedPluginModule = getSelectedPluginModule(repository.exportPlugins)
	if selectedPluginModule == None:
		replaceableExportChainGcode = exportChainGcode
	else:
		if selectedPluginModule.globalIsReplaceable:
			replaceableExportChainGcode = selectedPluginModule.getOutput(exportChainGcode)
		else:
			selectedPluginModule.writeOutput(suffixFileName, exportChainGcode)
	if replaceableExportChainGcode != None:
		replaceableExportChainGcode = getReplaced(replaceableExportChainGcode)
		archive.writeFileText( suffixFileName, replaceableExportChainGcode )
		print('The exported file is saved as ' + archive.getSummarizedFileName(suffixFileName))
	if repository.alsoSendOutputTo.value != '':
		if replaceableExportChainGcode == None:
			replaceableExportChainGcode = selectedPluginModule.getOutput(exportChainGcode)
		exec('print >> ' + repository.alsoSendOutputTo.value + ', replaceableExportChainGcode')
	print('It took %s to export the file.' % euclidean.getDurationString(time.time() - startTime))
	return window
Exemplo n.º 13
0
def writeOutput(fileName, shouldAnalyze=True):
    'Export a gcode linear move file.'

    if fileName == '':
        return None
    repository = ExportRepository()
    settings.getReadRepository(repository)
    startTime = time.time()
    print('File ' + archive.getSummarizedFileName(fileName) +
          ' is being chain exported.')
    fileNameSuffix = fileName[:fileName.rfind('.')]

    if repository.addExportSuffix.value:
        fileNameSuffix += '_export'

    if (repository.profileFileExtension.value == True):
        profileName = skeinforge_profile.getProfileName(
            skeinforge_profile.getCraftTypeName())
        if profileName:
            fileNameSuffix += '.' + string.replace(profileName, ' ', '_')

    if (repository.descriptiveExtension.value == True):
        fileNameSuffix += descriptiveExtension()

    if (repository.timestampExtension.value == True):
        fileNameSuffix += '.' + strftime("%Y%m%d_%H%M%S")

    if (repository.archiveProfile.value == True):
        profileName = skeinforge_profile.getProfileName(
            skeinforge_profile.getCraftTypeName())
        if profileName:
            profileZipFileName = fileNameSuffix + '.zip'
            zipper(
                archive.getProfilesPath(
                    skeinforge_profile.getProfileDirectory()),
                profileName + '/', profileZipFileName)
            print('Profile archived to ' + profileZipFileName)

    if (repository.exportProfileAsCsv.value == True):
        csvExportFilename = fileNameSuffix + '.csv'
        archive.writeFileText(csvExportFilename, Condenser().readSettings())

    fileNameSuffix += '.' + repository.fileExtension.value
    gcodeText = gcodec.getGcodeFileText(fileName, '')
    procedures = skeinforge_craft.getProcedures('export', gcodeText)
    gcodeText = skeinforge_craft.getChainTextFromProcedures(
        fileName, procedures[:-1], gcodeText)
    if gcodeText == '':
        return None
    if repository.savePenultimateGcode.value:
        penultimateFileName = fileName[:fileName.
                                       rfind('.')] + '_penultimate.gcode'
        archive.writeFileText(penultimateFileName, gcodeText)
        print('The penultimate file is saved as ' +
              archive.getSummarizedFileName(penultimateFileName))
    exportGcode = getCraftedTextFromText(gcodeText, repository)
    window = None
    if shouldAnalyze:
        window = skeinforge_analyze.writeOutput(fileName, fileNameSuffix,
                                                gcodeText)
    replaceableExportGcode = None
    selectedPluginModule = getSelectedPluginModule(repository.exportPlugins)
    if selectedPluginModule == None:
        replaceableExportGcode = exportGcode
    else:
        if selectedPluginModule.globalIsReplaceable:
            replaceableExportGcode = selectedPluginModule.getOutput(
                exportGcode)
        else:
            selectedPluginModule.writeOutput(fileNameSuffix, exportGcode)
    if replaceableExportGcode != None:
        replaceableExportGcode = getReplaceableExportGcode(
            repository.nameOfReplaceFile.value, replaceableExportGcode)
        archive.writeFileText(fileNameSuffix, replaceableExportGcode)
        print('The exported file is saved as ' +
              archive.getSummarizedFileName(fileNameSuffix))
    if repository.alsoSendOutputTo.value != '':
        if replaceableExportGcode == None:
            replaceableExportGcode = selectedPluginModule.getOutput(
                exportGcode)
        sendOutputTo(replaceableExportGcode, repository.alsoSendOutputTo.value)
    print('It took %s to export the file.' %
          euclidean.getDurationString(time.time() - startTime))

    return window
Exemplo n.º 14
0
def writeOutput(fileName, shouldAnalyze=True):
    """Export a gcode linear move file."""

    if fileName == '':
        return None
    repository = ExportRepository()
    settings.getReadRepository(repository)
    startTime = time.time()
    print('File ' + archive.getSummarizedFileName(fileName) + ' is being chain exported.')
    fileNameSuffix = fileName[: fileName.rfind('.')]

    if repository.addExportSuffix.value:
        fileNameSuffix += '_export'

    if repository.profileFileExtension.value:
        profileName = skeinforge_profile.getProfileName(skeinforge_profile.getCraftTypeName())
        if profileName:
            fileNameSuffix += '.' + string.replace(profileName, ' ', '_')

    if repository.descriptiveExtension.value:
        fileNameSuffix += descriptiveExtension()

    if repository.timestampExtension.value:
        fileNameSuffix += '.'+strftime("%Y%m%d_%H%M%S")

    if repository.archiveProfile.value:
        profileName = skeinforge_profile.getProfileName(skeinforge_profile.getCraftTypeName())
        if profileName:
            profileZipFileName = fileNameSuffix + '.zip'
            zipper(archive.getProfilesPath(skeinforge_profile.getProfileDirectory()), profileName+'/', profileZipFileName)
            print('Profile archived to ' + profileZipFileName)

    if repository.exportProfileAsCsv.value:
        csvExportFilename = fileNameSuffix + '.csv'
        archive.writeFileText(csvExportFilename, Condenser().readSettings())

    fileNameSuffix += '.' + repository.fileExtension.value
    gcodeText = gcodec.getGcodeFileText(fileName, '')
    procedures = skeinforge_craft.getProcedures('export', gcodeText)
    gcodeText = skeinforge_craft.getChainTextFromProcedures(fileName, procedures[ : - 1 ], gcodeText)
    if gcodeText == '':
        return None
    fileNamePenultimate = fileName[: fileName.rfind('.')] + '_penultimate.gcode'
    filePenultimateWritten = False
    if repository.savePenultimateGcode.value:
        archive.writeFileText(fileNamePenultimate, gcodeText)
        filePenultimateWritten = True
        print('The penultimate file is saved as ' + archive.getSummarizedFileName(fileNamePenultimate))
    exportGcode = getCraftedTextFromText(gcodeText, repository)
    window = None
    if shouldAnalyze:
        window = skeinforge_analyze.writeOutput(fileName, fileNamePenultimate, fileNameSuffix,
            filePenultimateWritten, gcodeText)
    replaceableExportGcode = None
    selectedPluginModule = getSelectedPluginModule(repository.exportPlugins)
    if selectedPluginModule is None:
        replaceableExportGcode = exportGcode
    else:
        if selectedPluginModule.globalIsReplaceable:
            replaceableExportGcode = selectedPluginModule.getOutput(exportGcode)
        else:
            selectedPluginModule.writeOutput(fileNameSuffix, exportGcode)
    if replaceableExportGcode is not None:
        replaceableExportGcode = getReplaceableExportGcode(repository.nameOfReplaceFile.value, replaceableExportGcode)
        archive.writeFileText( fileNameSuffix, replaceableExportGcode )
        print('The exported file is saved as ' + archive.getSummarizedFileName(fileNameSuffix))
    if repository.alsoSendOutputTo.value != '':
        if replaceableExportGcode is None:
            replaceableExportGcode = selectedPluginModule.getOutput(exportGcode)
        sendOutputTo(replaceableExportGcode, repository.alsoSendOutputTo.value)
    print('It took %s to export the file.' % euclidean.getDurationString(time.time() - startTime))

    return window