Esempio n. 1
0
def combine2python(input_str, output_path, project_name, encoding):
    """Extracts encoded string containing combine archive
    and generates Python scripts."""
    ipythonify.str2py(input_str, output_path, project_name, encoding)
    notebook = ipythonify.jsonify(output_path, project_name)
    dstloc = os.path.join(os.path.join(output_path, project_name), project_name + '.ipynb')
    with open(dstloc, "w") as notebook_file:
        notebook_file.write(notebook)
Esempio n. 2
0
def combine2python(input_str, output_path, project_name, encoding):
    """Extracts encoded string containing combine archive
    and generates Python scripts."""
    ipythonify.str2py(input_str, output_path, project_name, encoding)
    notebook = ipythonify.jsonify(output_path, project_name)
    dstloc = os.path.join(os.path.join(output_path, project_name),
                          project_name + '.ipynb')
    with open(dstloc, "w") as notebook_file:
        notebook_file.write(notebook)
Esempio n. 3
0
def openAsNotebook():
    # host = request.args.get('host')

    title = request.args.get('title', type=str)
    encin = request.args.get('format', type=str)
    archive = request.args.get('archive', type=str)
    host = request.args.get('host', type=str)
    ipythonify.pyprep(archive, dirname, title, encin)
    notebook = ipythonify.jsonify(os.path.join(dirname, title + '.py'), title)
    with open(os.path.join(dirname, title + '.ipynb'), "w") as notebook_file:
        notebook_file.write(notebook)

    return redirect('http://' + host + '/notebooks/' +
                    title + '.ipynb', code=302)
Esempio n. 4
0
def openAsNotebook():
    global processid
    title = request.args.get('title', type=str)
    encin = request.args.get('format', type=str)
    archive = request.args.get('archive', type=str)
    if processid == str():
        ipythonify.str2py(archive, dirname, title, encin)
        notebook = ipythonify.jsonify(dirname, title)
        dstloc = os.path.join(os.path.join(dirname, title), title + '.ipynb')
        with open(dstloc, "w") as notebook_file:
            notebook_file.write(notebook)
        if 'win32' in sys.platform:
            ipy = sp.Popen("ipython notebook --no-browser --matplotlib inline --ip=0.0.0.0 --notebook-dir=" + '"' + os.path.join(dirname, title) + '"')
            processid = str(ipy.pid)
        elif 'linux' or 'darwin' in sys.platform:
            ipy = sp.Popen(["ipython", "notebook", "--no-browser", "--matplotlib", "inline", "--ip=0.0.0.0", "--notebook-dir=" + os.path.join(dirname, title)])
            processid = str(ipy.pid)
    else:
        pass
    time.sleep(0.5)
    #print "pid is " + processid
    return redirect('http://' + 'localhost:8888' + '/notebooks/' + title + '.ipynb', code=302)