Beispiel #1
0
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
Beispiel #2
0
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
Beispiel #3
0
def view(html_snippet, copy_list, port):
    with make_tmp_folder() as tmp_dir:
        # First copy all brain maps
        for real_path, temp_path in copy_list.items():
            real_path = os.path.abspath(real_path.replace("file://", ""))
            shutil.copy(real_path, "%s/%s" % (tmp_dir, temp_path))
        # Now write template to temporary file
        tmp_file = "%s/pycompare.html" % (tmp_dir)
        # Change directory and start a web server
        os.chdir(tmp_dir)
        print(os.getcwd())
        write_file(html_snippet, tmp_file)
        tmp_file_base = os.path.basename(tmp_file)
        if port != None:
            httpd = run_webserver(html_page="%s" % (tmp_file_base), port=port)
        else:
            httpd = run_webserver(html_page="%s" % (tmp_file_base))
        return httpd
Beispiel #4
0
def view(html_snippet,copy_list,port):
    with make_tmp_folder() as tmp_dir:  
        # First copy all brain maps
        for real_path,temp_path in copy_list.iteritems():
            real_path = os.path.abspath(real_path.replace("file://",""))
            shutil.copy(real_path,"%s/%s" %(tmp_dir,temp_path))
        # Now write template to temporary file
        tmp_file = "%s/pycompare.html" %(tmp_dir)
        # Change directory and start a web server
        os.chdir(tmp_dir)
        print os.getcwd()
        write_file(html_snippet,tmp_file)
        tmp_file_base = os.path.basename(tmp_file)
        if port!=None:
            httpd = run_webserver(html_page="%s" %(tmp_file_base),port=port)
        else:
            httpd = run_webserver(html_page="%s" %(tmp_file_base))
        return httpd