mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
69 lines
2.0 KiB
Mako
69 lines
2.0 KiB
Mako
<%namespace name="ie" file="ie.mako" />
|
|
|
|
<%
|
|
import os
|
|
import shutil
|
|
import hashlib
|
|
|
|
# Sets ID and sets up a lot of other variables
|
|
ie_request.load_deploy_config()
|
|
ie_request.attr.docker_port = 6789
|
|
# Create tempdir in galaxy
|
|
temp_dir = ie_request.temp_dir
|
|
|
|
if ie_request.attr.PASSWORD_AUTH:
|
|
m = hashlib.sha1()
|
|
m.update( ie_request.notebook_pw + ie_request.notebook_pw_salt )
|
|
PASSWORD = 'sha1:%s:%s' % (ie_request.notebook_pw_salt, m.hexdigest())
|
|
else:
|
|
PASSWORD = "none"
|
|
|
|
## IPython Specific
|
|
# Prepare an empty notebook
|
|
notebook_id = ie_request.generate_hex(64)
|
|
with open( os.path.join( ie_request.attr.our_template_dir, 'notebook.ipynb' ), 'r') as nb_handle:
|
|
empty_nb = nb_handle.read()
|
|
empty_nb = empty_nb % notebook_id
|
|
# Copy over default notebook, unless the dataset this viz is running on is a notebook
|
|
empty_nb_path = os.path.join(temp_dir, 'ipython_galaxy_notebook.ipynb')
|
|
|
|
if hda.datatype.__class__.__name__ != "Ipynb":
|
|
with open( empty_nb_path, 'w+' ) as handle:
|
|
handle.write( empty_nb )
|
|
else:
|
|
shutil.copy( hda.file_name, empty_nb_path )
|
|
|
|
# Add all environment variables collected from Galaxy's IE infrastructure
|
|
ie_request.launch(env_override={
|
|
'notebook_password': PASSWORD,
|
|
})
|
|
|
|
## General IE specific
|
|
# Access URLs for the notebook from within galaxy.
|
|
notebook_access_url = ie_request.url_template('${PROXY_URL}/ipython/notebooks/ipython_galaxy_notebook.ipynb')
|
|
notebook_login_url = ie_request.url_template('${PROXY_URL}/ipython/login?next=${PROXY_PREFIX}%2Fipython%2Ftree')
|
|
|
|
%>
|
|
<html>
|
|
<head>
|
|
${ ie.load_default_js() }
|
|
</head>
|
|
<body>
|
|
|
|
<script type="text/javascript">
|
|
${ ie.default_javascript_variables() }
|
|
var notebook_login_url = '${ notebook_login_url }';
|
|
var notebook_access_url = '${ notebook_access_url }';
|
|
${ ie.plugin_require_config() }
|
|
|
|
// Load notebook
|
|
|
|
requirejs(['interactive_environments', 'plugin/ipython'], function(){
|
|
load_notebook(ie_password, notebook_login_url, notebook_access_url);
|
|
});
|
|
</script>
|
|
<div id="main" width="100%" height="100%">
|
|
</div>
|
|
</body>
|
|
</html>
|