コード例 #1
0
ファイル: cleave.py プロジェクト: weeberp/MakerDroid
def writeOutput(fileName=''):
    "Cleave a GNU Triangulated Surface file.  If no fileName is specified, cleave the first GNU Triangulated Surface file in this folder."
    if fileName == '':
        unmodified = gcodec.getFilesWithFileTypesWithoutWords(
            fabmetheus_interpret.getImportPluginFileNames())
        if len(unmodified) == 0:
            print("There are no carvable files in this folder.")
            return
        fileName = unmodified[0]
    startTime = time.time()
    print('File ' + gcodec.getSummarizedFileName(fileName) +
          ' is being cleaved.')
    cleaveGcode = getCraftedText(fileName)
    if cleaveGcode == '':
        return
    suffixFileName = fileName[:fileName.rfind('.')] + '_cleave.svg'
    suffixDirectoryName = os.path.dirname(suffixFileName)
    suffixReplacedBaseName = os.path.basename(suffixFileName).replace(' ', '_')
    suffixFileName = os.path.join(suffixDirectoryName, suffixReplacedBaseName)
    gcodec.writeFileText(suffixFileName, cleaveGcode)
    print('The cleaved file is saved as ' +
          gcodec.getSummarizedFileName(suffixFileName))
    print('It took ' + str(int(round(time.time() - startTime))) +
          ' seconds to cleave the file.')
    settings.openWebPage(suffixFileName)
コード例 #2
0
def getWindowAnalyzeFile(fileName, repository=None):
    'Open penultimate file with outside program.'
    print('')
    if repository == None:
        repository = settings.getReadRepository(ClairvoyanceRepository())
    gcodeProgram = repository.gcodeProgram.value
    if gcodeProgram == '':
        print(
            'Warning, nothing will be done in getWindowAnalyzeFile in clairvoyance because the Gcode Program field is empty.'
        )
        print('')
        return
    if gcodeProgram == 'webbrowser':
        print('Clairvoyance will use a web browser to open the file:')
        print(archive.getSummarizedFileName(fileName))
        settings.openWebPage(fileName)
        return
    try:
        subprocess.Popen([gcodeProgram, fileName])
        print('Clairvoyance has opened the file:')
        print(archive.getSummarizedFileName(fileName))
        print('with the gcode program:')
        print(gcodeProgram)
    except:
        print(
            'Warning, getWindowAnalyzeFile in clairvoyance could not open the file:'
        )
        print(fileName)
        print('with the gcode program:')
        print(gcodeProgram)
        print('Error traceback is the following:')
        traceback.print_exc(file=sys.stdout)
        print('')
コード例 #3
0
ファイル: fabmetheus_interpret.py プロジェクト: Aeva/SFACT
def getWindowAnalyzeFile(fileName):
	"Get file interpretion."
	startTime = time.time()
	carving = getCarving(fileName)
	if carving is None:
		return None
	interpretGcode = str( carving )
	if interpretGcode == '':
		return None
	repository = settings.getReadRepository( InterpretRepository() )
	if repository.printInterpretion.value:
		print( interpretGcode )
	suffixFileName = fileName[ : fileName.rfind('.') ] + '_interpret.' + carving.getInterpretationSuffix()
	suffixDirectoryName = os.path.dirname(suffixFileName)
	suffixReplacedBaseName = os.path.basename(suffixFileName).replace(' ', '_')
	suffixFileName = os.path.join( suffixDirectoryName, suffixReplacedBaseName )
	archive.writeFileText( suffixFileName, interpretGcode )
	print('The interpret file is saved as ' + archive.getSummarizedFileName(suffixFileName) )
	print('It took %s to interpret the file.' % euclidean.getDurationString( time.time() - startTime ) )
	textProgram = repository.textProgram.value
	if textProgram == '':
		return None
	if textProgram == 'webbrowser':
		settings.openWebPage(suffixFileName)
		return None
	textFilePath = '"' + os.path.normpath(suffixFileName) + '"' # " to send in file name with spaces
	shellCommand = textProgram + ' ' + textFilePath
	print('Sending the shell command:')
	print(shellCommand)
	commandResult = os.system(shellCommand)
	if commandResult != 0:
		print('It may be that the system could not find the %s program.' % textProgram )
		print('If so, try installing the %s program or look for another one, like Open Office which can be found at:' % textProgram )
		print('http://www.openoffice.org/')
		print('Open office writer can then be started from the command line with the command "soffice -writer".')
コード例 #4
0
ファイル: clairvoyance.py プロジェクト: folksjos/RepG
def getWindowAnalyzeFile(fileName, repository=None):
	'Open penultimate file with outside program.'
	print('')
	if repository == None:
		repository = settings.getReadRepository(ClairvoyanceRepository())
	gcodeProgram = repository.gcodeProgram.value
	if gcodeProgram == '':
		print('Warning, nothing will be done in getWindowAnalyzeFile in clairvoyance because the Gcode Program field is empty.')
		print('')
		return
	if gcodeProgram == 'webbrowser':
		print('Clairvoyance will use a web browser to open the file:')
		print(archive.getSummarizedFileName(fileName))
		settings.openWebPage(fileName)
		return
	try:
		subprocess.Popen([gcodeProgram, fileName])
		print('Clairvoyance has opened the file:')
		print(archive.getSummarizedFileName(fileName))
		print('with the gcode program:')
		print(gcodeProgram)
	except:
		print('Warning, getWindowAnalyzeFile in clairvoyance could not open the file:')
		print(fileName)
		print('with the gcode program:')
		print(gcodeProgram)
		print('Error traceback is the following:')
		traceback.print_exc(file=sys.stdout)
		print('')
コード例 #5
0
def getWindowAnalyzeFile(fileName):
	"Get file interpretion."
	startTime = time.time()
	carving = getCarving(fileName)
	if carving == None:
		return None
	interpretGcode = str( carving )
	if interpretGcode == '':
		return None
	repository = settings.getReadRepository( InterpretRepository() )
	if repository.printInterpretion.value:
		print(interpretGcode)
	suffixFileName = fileName[ : fileName.rfind('.') ] + '_interpret.' + carving.getInterpretationSuffix()
	suffixDirectoryName = os.path.dirname(suffixFileName)
	suffixReplacedBaseName = os.path.basename(suffixFileName).replace(' ', '_')
	suffixFileName = os.path.join( suffixDirectoryName, suffixReplacedBaseName )
	archive.writeFileText( suffixFileName, interpretGcode )
	print('The interpret file is saved as ' + archive.getSummarizedFileName(suffixFileName) )
	print('It took %s to interpret the file.' % euclidean.getDurationString( time.time() - startTime ) )
	textProgram = repository.textProgram.value
	if textProgram == '':
		return None
	if textProgram == 'webbrowser':
		settings.openWebPage(suffixFileName)
		return None
	textFilePath = '"' + os.path.normpath(suffixFileName) + '"' # " to send in file name with spaces
	shellCommand = textProgram + ' ' + textFilePath
	print('Sending the shell command:')
	print(shellCommand)
	commandResult = os.system(shellCommand)
	if commandResult != 0:
		print('It may be that the system could not find the %s program.' % textProgram )
		print('If so, try installing the %s program or look for another one, like Open Office which can be found at:' % textProgram )
		print('http://www.openoffice.org/')
		print('Open office writer can then be started from the command line with the command "soffice -writer".')
コード例 #6
0
ファイル: carve.py プロジェクト: aliensr85/Skeinforge-Mirror
def writeOutput( fileName = '' ):
	"Carve a GNU Triangulated Surface file."
	startTime = time.time()
	print( 'File ' + gcodec.getSummarizedFileName( fileName ) + ' is being carved.' )
	carveGcode = getCraftedText( fileName )
	if carveGcode == '':
		return
	suffixFileName = gcodec.getFilePathWithUnderscoredBasename( fileName, '_carve.svg' )
	gcodec.writeFileText( suffixFileName, carveGcode )
	print( 'The carved file is saved as ' + gcodec.getSummarizedFileName( suffixFileName ) )
	print( 'It took %s to carve the file.' % euclidean.getDurationString( time.time() - startTime ) )
	settings.openWebPage( suffixFileName )
コード例 #7
0
	def execute(self):
		"Export the canvas as an svg file."
		svgFileName = archive.getFilePathWithUnderscoredBasename( self.fileName, self.suffix )
		boundingBox = self.canvas.bbox( settings.Tkinter.ALL ) # tuple (w, n, e, s)
		self.boxW = boundingBox[0]
		self.boxN = boundingBox[1]
		boxWidth = boundingBox[2] - self.boxW
		boxHeight = boundingBox[3] - self.boxN
		print('Exported svg file saved as ' + svgFileName )
		svgTemplateText = archive.getFileTextInFileDirectory( settings.__file__, os.path.join('templates', 'canvas_template.svg') )
		output = cStringIO.StringIO()
		lines = archive.getTextLines( svgTemplateText )
		firstWordTable = {}
		firstWordTable['height="999px"'] = '		height="%spx"' % int( round( boxHeight ) )
		firstWordTable['<!--replaceLineWith_coloredLines-->'] = self.getCanvasLinesOutput()
		firstWordTable['replaceLineWithTitle'] = archive.getSummarizedFileName( self.fileName )
		firstWordTable['width="999px"'] = '		width="%spx"' % int( round( boxWidth ) )
		for line in lines:
			parseLineReplace( firstWordTable, line, output )
		archive.writeFileText( svgFileName, output.getvalue() )
		fileExtension = self.fileExtension.value
		svgViewer = self.svgViewer.value
		if svgViewer == '':
			return
		if svgViewer == 'webbrowser':
			settings.openWebPage( svgFileName )
			return
		svgFilePath = '"' + os.path.normpath( svgFileName ) + '"' # " to send in file name with spaces
		shellCommand = svgViewer + ' ' + svgFilePath
		print('')
		if fileExtension == '':
			print('Sending the shell command:')
			print( shellCommand )
			commandResult = os.system( shellCommand )
			if commandResult != 0:
				print('It may be that the system could not find the %s program.' % svgViewer )
				print('If so, try installing the %s program or look for another svg viewer, like Netscape which can be found at:' % svgViewer )
				print('http://www.netscape.org/')
			return
		convertedFileName = archive.getFilePathWithUnderscoredBasename( svgFilePath, '.' + fileExtension + '"')
		shellCommand += ' ' + convertedFileName
		print('Sending the shell command:')
		print( shellCommand )
		commandResult = os.system( shellCommand )
		if commandResult != 0:
			print('The %s program could not convert the svg to the %s file format.' % ( svgViewer, fileExtension ) )
			print('Try installing the %s program or look for another one, like Image Magick which can be found at:' % svgViewer )
			print('http://www.imagemagick.org/script/index.php')
コード例 #8
0
ファイル: vectorwrite.py プロジェクト: chriskyfung/MakerDroid
def analyzeFileGivenText( fileName, gcodeText, repository = None ):
	"Write scalable vector graphics for a gcode file given the settings."
	if gcodeText == '':
		return ''
	if repository == None:
		repository = settings.getReadRepository( VectorwriteRepository() )
	startTime = time.time()
	vectorwriteGcode = VectorwriteSkein().getSVG( fileName, gcodeText, repository )
	if vectorwriteGcode == '':
		return
	suffixFileName = fileName[ : fileName.rfind( '.' ) ] + '_vectorwrite.svg'
	suffixDirectoryName = os.path.dirname( suffixFileName )
	suffixReplacedBaseName = os.path.basename( suffixFileName ).replace( ' ', '_' )
	suffixFileName = os.path.join( suffixDirectoryName, suffixReplacedBaseName )
	gcodec.writeFileText( suffixFileName, vectorwriteGcode )
	print( 'The vectorwrite file is saved as ' + gcodec.getSummarizedFileName( suffixFileName ) )
	print( 'It took ' + str( int( round( time.time() - startTime ) ) ) + ' seconds to vectorwrite the file.' )
	settings.openWebPage( suffixFileName )
コード例 #9
0
def analyzeFileGivenText(fileName, gcodeText, repository=None):
    "Write scalable vector graphics for a gcode file given the settings."
    if gcodeText == "":
        return ""
    if repository == None:
        repository = settings.getReadRepository(VectorwriteRepository())
    startTime = time.time()
    vectorwriteGcode = VectorwriteSkein().getCarvedSVG(fileName, gcodeText, repository)
    if vectorwriteGcode == "":
        return
    suffixFileName = fileName[: fileName.rfind(".")] + "_vectorwrite.svg"
    suffixDirectoryName = os.path.dirname(suffixFileName)
    suffixReplacedBaseName = os.path.basename(suffixFileName).replace(" ", "_")
    suffixFileName = os.path.join(suffixDirectoryName, suffixReplacedBaseName)
    gcodec.writeFileText(suffixFileName, vectorwriteGcode)
    print("The vectorwrite file is saved as " + gcodec.getSummarizedFileName(suffixFileName))
    print("It took %s to vectorwrite the file." % euclidean.getDurationString(time.time() - startTime))
    settings.openWebPage(suffixFileName)
コード例 #10
0
def analyzeFileGivenText( fileName, gcodeText, repository = None ):
	"Write scalable vector graphics for a gcode file given the settings."
	if gcodeText == '':
		return ''
	if repository == None:
		repository = settings.getReadRepository( VectorwriteRepository() )
	startTime = time.time()
	vectorwriteGcode = VectorwriteSkein().getCarvedSVG( fileName, gcodeText, repository )
	if vectorwriteGcode == '':
		return
	suffixFileName = fileName[ : fileName.rfind( '.' ) ] + '_vectorwrite.svg'
	suffixDirectoryName = os.path.dirname( suffixFileName )
	suffixReplacedBaseName = os.path.basename( suffixFileName ).replace( ' ', '_' )
	suffixFileName = os.path.join( suffixDirectoryName, suffixReplacedBaseName )
	gcodec.writeFileText( suffixFileName, vectorwriteGcode )
	print( 'The vectorwrite file is saved as ' + gcodec.getSummarizedFileName( suffixFileName ) )
	print( 'It took %s to vectorwrite the file.' % euclidean.getDurationString( time.time() - startTime ) )
	settings.openWebPage( suffixFileName )
コード例 #11
0
ファイル: cleave.py プロジェクト: chriskyfung/MakerDroid
def writeOutput( fileName = '' ):
	"Cleave a GNU Triangulated Surface file.  If no fileName is specified, cleave the first GNU Triangulated Surface file in this folder."
	if fileName == '':
		unmodified = gcodec.getFilesWithFileTypesWithoutWords( fabmetheus_interpret.getImportPluginFileNames() )
		if len( unmodified ) == 0:
			print( "There are no carvable files in this folder." )
			return
		fileName = unmodified[ 0 ]
	startTime = time.time()
	print( 'File ' + gcodec.getSummarizedFileName( fileName ) + ' is being cleaved.' )
	cleaveGcode = getCraftedText( fileName )
	if cleaveGcode == '':
		return
	suffixFileName = fileName[ : fileName.rfind( '.' ) ] + '_cleave.svg'
	suffixDirectoryName = os.path.dirname( suffixFileName )
	suffixReplacedBaseName = os.path.basename( suffixFileName ).replace( ' ', '_' )
	suffixFileName = os.path.join( suffixDirectoryName, suffixReplacedBaseName )
	gcodec.writeFileText( suffixFileName, cleaveGcode )
	print( 'The cleaved file is saved as ' + gcodec.getSummarizedFileName( suffixFileName ) )
	print( 'It took ' + str( int( round( time.time() - startTime ) ) ) + ' seconds to cleave the file.' )
	settings.openWebPage( suffixFileName )