Skip to content

Commit d1111af

Browse files
authored
Merge pull request #159 from marscher/fix_static_files_in_user_target
[launcher] deploy static files to users copy of notebooks
2 parents 2f87730 + 8ab3ec8 commit d1111af

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

pyemma_tutorials/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
__version__ = get_versions()['version']
77
del get_versions
88

9-
from .util import notebook_location, configs_location
9+
from .util import notebook_location, configs_location, run_dir

pyemma_tutorials/jupyter_notebook_config.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,7 @@
214214
c.Examples.unreviewed_example_dir = ''
215215

216216
## The directory to use for notebooks and kernels.
217-
import os
218-
run_dir = os.path.expanduser('~/pyemma_tutorials')
219-
os.makedirs(run_dir, exist_ok=True)
217+
run_dir = pyemma_tutorials.run_dir()
220218
c.NotebookApp.notebook_dir = run_dir
221219

222220
## Whether to open in a browser after starting. The specific browser used is

pyemma_tutorials/util.py

+25
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,28 @@ def configs_location():
1616
assert os.path.exists(notebook_cfg_json)
1717

1818
return notebook_cfg, notebook_cfg_json
19+
20+
21+
def run_dir():
22+
""" directory in which the user copies of the notebooks will reside. """
23+
import os
24+
target = os.path.expanduser('~/pyemma_tutorials')
25+
os.makedirs(target, exist_ok=True)
26+
27+
# copy static data into run dir
28+
src = os.path.join(notebook_location(), 'static')
29+
30+
def copytree(src, dst, symlinks=False, ignore=None):
31+
# shutil.copytree fails for existing target dirs...
32+
import shutil
33+
for item in os.listdir(src):
34+
s = os.path.join(src, item)
35+
d = os.path.join(dst, item)
36+
if os.path.isdir(s):
37+
shutil.copytree(s, d, symlinks, ignore)
38+
else:
39+
shutil.copy2(s, d)
40+
41+
copytree(src, os.path.join(target, 'static'))
42+
43+
return target

0 commit comments

Comments
 (0)