def readSettings(self): self.output = cStringIO.StringIO() profileDirectory = skeinforge_profile.getProfileDirectory() craftRepo = skeinforge_craft.CraftRepository() profileBaseName = settings.getProfileBaseName( craftRepo ) allCraftNames = archive.getPluginFileNamesFromDirectoryPath( skeinforge_craft.getPluginsDirectoryPath() ) fullProfilePath = os.path.join( archive.getSettingsPath() , 'profiles' ) fullProfileDirectory = os.path.join( fullProfilePath , profileDirectory ) for craftName in allCraftNames: pluginModule = archive.getModuleWithPath(os.path.join( skeinforge_craft.getPluginsDirectoryPath(), craftName )) repo = pluginModule.getNewRepository() self.outputSettings(craftName, settings.getReadRepository(repo).preferences) return self.output.getvalue()
def readSettings(self): self.output = cStringIO.StringIO() profileDirectory = skeinforge_profile.getProfileDirectory() craftRepo = skeinforge_craft.CraftRepository() profileBaseName = settings.getProfileBaseName(craftRepo) allCraftNames = archive.getPluginFileNamesFromDirectoryPath( skeinforge_craft.getPluginsDirectoryPath()) fullProfilePath = os.path.join(archive.getSettingsPath(), 'profiles') fullProfileDirectory = os.path.join(fullProfilePath, profileDirectory) for craftName in allCraftNames: pluginModule = archive.getModuleWithPath( os.path.join(skeinforge_craft.getPluginsDirectoryPath(), craftName)) repo = pluginModule.getNewRepository() self.outputSettings(craftName, settings.getReadRepository(repo).preferences) return self.output.getvalue()
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
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