mirror of
https://github.com/jupyter/docker-stacks.git
synced 2025-10-11 20:12:58 +00:00
pre-commit: run black autoformatter on all files
This commit is contained in:

committed by
Erik Sundell

parent
a99a182940
commit
fe3968efe0
@@ -8,7 +8,7 @@ import errno
|
||||
import stat
|
||||
|
||||
c = get_config() # noqa: F821
|
||||
c.NotebookApp.ip = '0.0.0.0'
|
||||
c.NotebookApp.ip = "0.0.0.0"
|
||||
c.NotebookApp.port = 8888
|
||||
c.NotebookApp.open_browser = False
|
||||
|
||||
@@ -16,9 +16,9 @@ c.NotebookApp.open_browser = False
|
||||
c.FileContentsManager.delete_to_trash = False
|
||||
|
||||
# Generate a self-signed certificate
|
||||
if 'GEN_CERT' in os.environ:
|
||||
if "GEN_CERT" in os.environ:
|
||||
dir_name = jupyter_data_dir()
|
||||
pem_file = os.path.join(dir_name, 'notebook.pem')
|
||||
pem_file = os.path.join(dir_name, "notebook.pem")
|
||||
try:
|
||||
os.makedirs(dir_name)
|
||||
except OSError as exc: # Python >2.5
|
||||
@@ -28,28 +28,42 @@ if 'GEN_CERT' in os.environ:
|
||||
raise
|
||||
|
||||
# Generate an openssl.cnf file to set the distinguished name
|
||||
cnf_file = os.path.join(os.getenv('CONDA_DIR', '/usr/lib'), 'ssl', 'openssl.cnf')
|
||||
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('''\
|
||||
with open(cnf_file, "w") as fh:
|
||||
fh.write(
|
||||
"""\
|
||||
[req]
|
||||
distinguished_name = req_distinguished_name
|
||||
[req_distinguished_name]
|
||||
''')
|
||||
"""
|
||||
)
|
||||
|
||||
# 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])
|
||||
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
|
||||
|
||||
# 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))
|
||||
if "NB_UMASK" in os.environ:
|
||||
os.umask(int(os.environ["NB_UMASK"], 8))
|
||||
|
Reference in New Issue
Block a user