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].
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/0b075d02-3afb-44bd-9003-b3ad34a4975f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.