Super. You’ve put me on the right track.
Instead of --ServerApp.root_dir
I had to use --ContentsManager.root_dir,
but now it works.
Thanks a lot.
#
# https://raw.githubusercontent.com/ideonate/cdsdashboards/master/cdsdashboards/hubextension/spawners/variableusercreating.py
# https://raw.githubusercontent.com/ideonate/cdsdashboards/master/cdsdashboards/hubextension/spawners/variablesystemd.py
# https://raw.githubusercontent.com/jupyterhub/systemdspawner/main/systemdspawner/systemdspawner.py
#
import pwd
import os
from cdsdashboards.hubextension.spawners.variableusercreating import VariableUserCreatingSpawner
class myVariableUserCreatingSpawner(VariableUserCreatingSpawner):
def get_args(self):
try:
unix_username = self._expand_user_vars(self.username_template)
pwnam = pwd.getpwnam(unix_username)
except KeyError:
self.log.exception(f"No user named {unix_username} found in the system")
raise
pwnam.pw_name
wd = pwnam.pw_dir
# If Named Server, use a subdirectory within the home directory
if self.name:
subdir = "".join(ch for ch in self.name if (ch.isalnum() or ch in " _-#"))
wd = os.path.join(wd, subdir) + "/"
self.log.error("Using " + wd)
if os.path.exists(wd):
pass
else:
os.mkdir(wd)
uid = pwd.getpwnam(pwnam.pw_name).pw_uid
gid = grp.getgrnam(pwnam.pw_name).gr_gid
os.chown(wd, uid, gid)
self.log.error(f"XXX User-Dir {pwnam.pw_dir} Named Server: {self.name} Direcotry {wd} User: { pwnam.pw_name } ")
args = list(super().get_args())
#args.append("--ServerApp.root_dir=" + wd)
args.append("--ContentsManager.root_dir=" + wd)
return args
c.JupyterHub.spawner_class = myVariableUserCreatingSpawner
c.SystemdSpawner.unit_name_template = 'jupyter-{USERNAME}{DASHSERVERNAME}'
c.JupyterHub.allow_named_servers = True
c.CDSDashboardsConfig.builder_class = 'cdsdashboards.builder.processbuilder.ProcessBuilder'
from cdsdashboards.app import CDS_TEMPLATE_PATHS
from cdsdashboards.hubextension import cds_extra_handlers
c.JupyterHub.template_paths = CDS_TEMPLATE_PATHS
c.JupyterHub.extra_handlers = cds_extra_handlers