Skip to content

Commit

Permalink
Specify wildcard address correctly and disable trash function
Browse files Browse the repository at this point in the history
The syntax for telling the notebook to listen on all addresses has
changed, see jupyter/docker-stacks#721.

Also, this change disables trash functionality which should help resolve
https://jira.cybera.ca/browse/CAN-81. See
jupyter/notebook#3130 for more details.

Signed-off-by: Ian Allison <[email protected]>
  • Loading branch information
ianabc committed Dec 12, 2018
1 parent ef99941 commit 136d249
Showing 1 changed file with 28 additions and 27 deletions.
55 changes: 28 additions & 27 deletions pims-minimal/jupyter_notebook_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,34 @@
import stat

c = get_config()
c.NotebookApp.ip = '0.0.0.0'
c.NotebookApp.port = 8888
c.NotebookApp.open_browser = False

if 'JUPYTERHUB_API_TOKEN' not in os.environ:
c.NotebookApp.ip = '*'
c.NotebookApp.port = 8888
c.NotebookApp.open_browser = False

# Generate a self-signed certificate
if 'GEN_CERT' in os.environ:
dir_name = jupyter_data_dir()
pem_file = os.path.join(dir_name, 'notebook.pem')
try:
os.makedirs(dir_name)
except OSError as exc: # Python >2.5
if exc.errno == errno.EEXIST and os.path.isdir(dir_name):
pass
else:
raise
# Generate a certificate if one doesn't exist on disk
subprocess.check_call(['openssl', 'req', '-new',
'-newkey', 'rsa:2048',
'-days', '365',
'-nodes', '-x509',
'-subj', '/C=XX/ST=XX/L=XX/O=generated/CN=generated',
'-keyout', pem_file,
'-out', pem_file])
# Restrict access to the file
os.chmod(pem_file, stat.S_IRUSR | stat.S_IWUSR)
c.NotebookApp.certfile = pem_file
# https://github.com/jupyter/notebook/issues/3130
c.FileContentsManager.delete_to_trash = False

# Generate a self-signed certificate
if 'GEN_CERT' in os.environ:
dir_name = jupyter_data_dir()
pem_file = os.path.join(dir_name, 'notebook.pem')
try:
os.makedirs(dir_name)
except OSError as exc: # Python >2.5
if exc.errno == errno.EEXIST and os.path.isdir(dir_name):
pass
else:
raise
# Generate a certificate if one doesn't exist on disk
subprocess.check_call(['openssl', 'req', '-new',
'-newkey', 'rsa:2048',
'-days', '365',
'-nodes', '-x509',
'-subj', '/C=XX/ST=XX/L=XX/O=generated/CN=generated',
'-keyout', pem_file,
'-out', pem_file])
# Restrict access to the file
os.chmod(pem_file, stat.S_IRUSR | stat.S_IWUSR)
c.NotebookApp.certfile = pem_file

c.NotebookApp.extra_template_paths = ["/opt/notebook/local_templates/"]

0 comments on commit 136d249

Please sign in to comment.