コード例 #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)
コード例 #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)
コード例 #3
0
def openAsSpyder():
    title = request.args.get('title', type=str)
    encin = request.args.get('format', type=str)
    archive = request.args.get('archive', type=str)
    ipythonify.str2py(archive, dirname, title, encin)
    dstloc = os.path.join(os.path.join(dirname, title), title + '.py')
    if 'win32' in sys.platform:
        sp.Popen("spyder " + '"' + dstloc + '"', shell=True)
    elif 'linux' or 'darwin' in sys.platform:
        sp.Popen(["spyder", dstloc], shell=True)
    return render_template('pickHost.html')
コード例 #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)