Thanks for the reply. As far as I can tell, the user name is only accessible from the server side, thus the need for python. I tried writing a notebook server extension <https://jupyter-notebook.readthedocs.io/en/stable/extending/handlers.html#writing-a-notebook-server-extension> but that is intended for "RESTful API handlers" which is a bit beyond my abilities.
I'll try opening an issue on Jupyterhub. On Monday, October 23, 2017 at 5:56:33 AM UTC-4, takowl wrote: > > I think the issue is that output which doesn't come from executing a cell > is not displayed (in the case of Javascript, that means not run). You might > be able to make this more easily as an nbextension (a Javascript extension > for the Jupyter notebook interface). I don't know if the current username > is directly accessible from Javascript in Jupyterhub. > > You might also want to open an issue on Jupyterhub for an officially > supported way to do the same thing. > > On 22 October 2017 at 17:15, Scott Calabrese Barton <[email protected] > <javascript:>> wrote: > >> As a supervisor I log into a lot of different JupyterHub accounts, and >> I'd like to be able to see the username of the current login. I wrote a >> short iPython extension >> <http://ipython.readthedocs.io/en/stable/config/extensions/index.html> >> below, which adds the username to the kernel_logo_widget element. It >> works with the %load_ext magic, but I'm not sure how to make it work >> when automatically loaded. >> >> I've tried adding the following to ipython_kernel_config.py: >> >> c.IPKernelApp.extensions = [ 'NameInHeader' ] >> >> >> with the idea that the extension would load with the kernel. This loads >> the extension, but maybe too soon because the header is not changed. Is >> there a better way to accomplish what I'm trying to do? >> >> # NameInHeader.py >> >> def load_ipython_extension(ipython): >> >> import re, os >> from IPython.display import display, Javascript >> >> uname= os.getenv('USER') >> >> s='''var s = document.getElementById('kernel_logo_widget').innerHTML; >> var news= '<span style=\\'color:#919191\\'>_user_ </span>' + s; >> document.getElementById('kernel_logo_widget').innerHTML=news; >> ''' >> >> func=re.compile('_user_') >> s=func.sub(uname, s) >> >> display(Javascript(s)) >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Project Jupyter" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/jupyter/0b075d02-3afb-44bd-9003-b3ad34a4975f%40googlegroups.com >> >> <https://groups.google.com/d/msgid/jupyter/0b075d02-3afb-44bd-9003-b3ad34a4975f%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "Project Jupyter" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/9705841c-ef7f-4148-9db7-985e9c032222%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
