mirror of
https://github.com/jupyter/docker-stacks.git
synced 2025-10-07 10:04:03 +00:00

* Removing inkscape * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Adding Rprofile to add plot_mimetypes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update datascience-notebook/Dockerfile Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com> * Update datascience-notebook/Rprofile.site Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com> * Adding R notebook tests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Moving Rprofile.site to minimal; Removing duplicate R test code * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fixing flake8 errors * Update minimal-notebook/Dockerfile Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com> * Update minimal-notebook/Rprofile.site Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com> * Removing empty line * Renaming minetypes to mimetypes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Renaming test module to avoid mypy error * Adding to jupyter.plot_mimetypes * Update R_mimetype_check.py * Update test_mimetypes.py * Update test_R_mimetypes.py * Update test_R_mimetypes.py Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Ayaz Salikhov <mathbunnyru@users.noreply.github.com>
61 lines
1.8 KiB
Python
61 lines
1.8 KiB
Python
# Copyright (c) Jupyter Development Team.
|
|
# Distributed under the terms of the Modified BSD License.
|
|
# mypy: ignore-errors
|
|
import os
|
|
import stat
|
|
import subprocess
|
|
|
|
from jupyter_core.paths import jupyter_data_dir
|
|
|
|
c = get_config() # noqa: F821
|
|
c.ServerApp.ip = "0.0.0.0"
|
|
c.ServerApp.port = 8888
|
|
c.ServerApp.open_browser = False
|
|
|
|
# to output both image/svg+xml and application/pdf plot formats in the notebook file
|
|
c.InlineBackend.figure_formats = {"png", "jpeg", "svg", "pdf"}
|
|
|
|
# https://github.com/jupyter/notebook/issues/3130
|
|
c.FileContentsManager.delete_to_trash = False
|
|
|
|
# Generate a self-signed certificate
|
|
OPENSSL_CONFIG = """\
|
|
[req]
|
|
distinguished_name = req_distinguished_name
|
|
[req_distinguished_name]
|
|
"""
|
|
if "GEN_CERT" in os.environ:
|
|
dir_name = jupyter_data_dir()
|
|
pem_file = os.path.join(dir_name, "notebook.pem")
|
|
os.makedirs(dir_name, exist_ok=True)
|
|
|
|
# Generate an openssl.cnf file to set the distinguished name
|
|
cnf_file = os.path.join(os.getenv("CONDA_DIR", "/usr/lib"), "ssl", "openssl.cnf")
|
|
if not os.path.isfile(cnf_file):
|
|
with open(cnf_file, "w") as fh:
|
|
fh.write(OPENSSL_CONFIG)
|
|
|
|
# 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",
|
|
f"-keyout={pem_file}",
|
|
f"-out={pem_file}",
|
|
]
|
|
)
|
|
# Restrict access to the file
|
|
os.chmod(pem_file, stat.S_IRUSR | stat.S_IWUSR)
|
|
c.ServerApp.certfile = pem_file
|
|
|
|
# Change default umask for all subprocesses of the notebook server if set in
|
|
# the environment
|
|
if "NB_UMASK" in os.environ:
|
|
os.umask(int(os.environ["NB_UMASK"], 8))
|