def get_svg_html(mpl_figures): svg_images = [] with make_tmp_folder() as tmp_dir: for fig in mpl_figures: tmp_svg = "%s/mplfig.svg" %(tmp_dir) fig.savefig(tmp_svg) fig_data = open(tmp_svg,"rb").readlines() svg_images.append(fig_data) return svg_images
def get_svg_html(mpl_figures): svg_images = [] with make_tmp_folder() as tmp_dir: for fig in mpl_figures: tmp_svg = "%s/mplfig.svg" % (tmp_dir) fig.savefig(tmp_svg) fig_data = open(tmp_svg, "rb").readlines() svg_images.append(fig_data) return svg_images
def view(html_snippet,real_paths=None,new_paths=None,url_vars=None): with make_tmp_folder() as tmp_dir: if real_paths: if len(real_paths) != len(real_paths): print "ERROR: mismatch in length of real and new temp paths." return for p in range(len(real_paths)): # Generate a new file name shutil.copy(real_paths[p],"%s/%s" %(tmp_dir,new_paths[p])) # Write to temporary file tmp_file = "%s/pycompare.html" %(tmp_dir) os.chdir(tmp_dir) print os.getcwd() write_file(html_snippet,tmp_file) tmp_file_base = os.path.basename(tmp_file) httpd = run_webserver(html_page="%s%s" %(tmp_file_base,url_vars)) return httpd
def view(html_snippet, real_paths=None, new_paths=None, url_vars=None): with make_tmp_folder() as tmp_dir: if real_paths: if len(real_paths) != len(real_paths): print "ERROR: mismatch in length of real and new temp paths." return for p in range(len(real_paths)): # Generate a new file name shutil.copy(real_paths[p], "%s/%s" % (tmp_dir, new_paths[p])) # Write to temporary file tmp_file = "%s/pycompare.html" % (tmp_dir) os.chdir(tmp_dir) print os.getcwd() write_file(html_snippet, tmp_file) tmp_file_base = os.path.basename(tmp_file) httpd = run_webserver(html_page="%s%s" % (tmp_file_base, url_vars)) return httpd