def conv_gsch2png(schpath, outfolder, include_extension=False): schpath = os.path.normpath(schpath) if include_extension is False: schfname, ext = os.path.splitext(os.path.split(schpath)[1]) else: schfname = os.path.split(schpath)[1] outpath = os.path.join(outfolder, schfname + '.png') epspath = os.path.join(outfolder, schfname + '.eps') if USE_SYSTEM_GAF_BIN and sym2eps: try: sym2eps.convert(schpath, epspath) except RuntimeError: logger.error( "SYM2EPS Segmentation Fault on symbol : " + schpath ) gschem_pngcmd = [ "convert", epspath, "-transparent", "white", outpath ] subprocess.call(gschem_pngcmd) try: os.remove(epspath) except OSError: logger.warning("Temporary .eps file not found to remove : " + epspath) else: gaf_pngcmd = [ os.path.join(GAF_BIN_ROOT, 'gaf'), 'export', '-c', '-o', outpath, schpath ] subprocess.call(gaf_pngcmd) return outpath
def conv_gsch2png(schpath, outfolder, include_extension=False): schpath = os.path.normpath(schpath) if include_extension is False: schfname, ext = os.path.splitext(os.path.split(schpath)[1]) else: schfname = os.path.split(schpath)[1] outpath = os.path.join(outfolder, schfname + '.png') epspath = os.path.join(outfolder, schfname + '.eps') if USE_SYSTEM_GAF_BIN: try: sym2eps.convert(schpath, epspath) except RuntimeError: logger.error( "SYM2EPS Segmentation Fault on symbol : " + schpath ) gschem_pngcmd = [ "convert", epspath, "-transparent", "white", outpath ] subprocess.call(gschem_pngcmd) try: os.remove(epspath) except OSError: logger.warning("Temporary .eps file not found to remove : " + epspath) else: gaf_pngcmd = [ os.path.join(GAF_BIN_ROOT, 'gaf'), 'export', '-c', '-o', outpath, schpath ] subprocess.call(gaf_pngcmd) return outpath
def test_sym2eps(): if os.path.exists('test/output.eps'): os.remove('test/output.eps') import sym2eps sym2eps.convert('test/symbol.sym', 'test/output.eps') assert os.path.exists('test/output.eps') == True