mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-08 02:24:08 +00:00
run autoformat
apologies to anyone finding this commit via git blame or log run the autoformatting by pre-commit run --all-files
This commit is contained in:
@@ -5,24 +5,28 @@ create a directory for the user before the spawner starts
|
||||
# pylint: disable=import-error
|
||||
import os
|
||||
import shutil
|
||||
|
||||
from jupyter_client.localinterfaces import public_ips
|
||||
|
||||
|
||||
def create_dir_hook(spawner):
|
||||
""" Create directory """
|
||||
username = spawner.user.name # get the username
|
||||
username = spawner.user.name # get the username
|
||||
volume_path = os.path.join('/volumes/jupyterhub', username)
|
||||
if not os.path.exists(volume_path):
|
||||
os.mkdir(volume_path, 0o755)
|
||||
# now do whatever you think your user needs
|
||||
# ...
|
||||
|
||||
|
||||
def clean_dir_hook(spawner):
|
||||
""" Delete directory """
|
||||
username = spawner.user.name # get the username
|
||||
username = spawner.user.name # get the username
|
||||
temp_path = os.path.join('/volumes/jupyterhub', username, 'temp')
|
||||
if os.path.exists(temp_path) and os.path.isdir(temp_path):
|
||||
shutil.rmtree(temp_path)
|
||||
|
||||
|
||||
# attach the hook functions to the spawner
|
||||
# pylint: disable=undefined-variable
|
||||
c.Spawner.pre_spawn_hook = create_dir_hook
|
||||
@@ -37,4 +41,4 @@ c.DockerSpawner.container_ip = "0.0.0.0"
|
||||
# You can now mount the volume to the docker container as we've
|
||||
# made sure the directory exists
|
||||
# pylint: disable=bad-whitespace
|
||||
c.DockerSpawner.volumes = { '/volumes/jupyterhub/{username}/': '/home/jovyan/work' }
|
||||
c.DockerSpawner.volumes = {'/volumes/jupyterhub/{username}/': '/home/jovyan/work'}
|
||||
|
Reference in New Issue
Block a user