I don’t think that is universal @CatChenal. To get your function to return True
, I needed to change jupyter-lab-script
to jupyter-notebook
inside a notebook running in JupyterLab that was running via MyBinder, which is a fancy JupyterHub.
Here’s what psutil.Process().parent().cmdline()
returns inside my current JupyterLab session with the token anonymized:
['/srv/conda/envs/notebook/bin/python',
'/srv/conda/envs/notebook/bin/jupyter-notebook',
'--ip=0.0.0.0',
'--port=8888',
'--NotebookApp.base_url=/user/fomightez-hhsuite3-binder-gru3g8n3/',
'--NotebookApp.token=XXXXXXXXXXXXX',
'--NotebookApp.trust_xheaders=True',
'--NotebookApp.allow_origin=*']
For completeness, I should add that I got back the same from psutil.Process().parent().cmdline()
, whether I was running in classic notebook or JupyterLab notebook interface on that hub.