Passing tornado_settings as an argument for launch_new_instance?

149 views
Skip to first unread message

Young Park

unread,
Aug 17, 2017, 3:43:31 PM8/17/17
to Project Jupyter
Hi,

I'm trying to write a python script that would launch the Jupyter Notebook server with the additional arguments and had some issues passing the tornado_settings as an argument to launch_new_instance.

All the other settings are being passed and are set correctly, but when tornado_setting is passed as an argument, it works on some machines and doesn't on others.

Here's the code of what I am trying to do:

args += ['--NotebookApp.allow_origin="*"',
             
'--NotebookApp.disable_check_xsrf=True',
             
'--NotebookApp.trust_xheaders=True',
             
'--NotebookApp.open_browser=False',
             
'--NotebookApp.token=""',
             
'--NotebookApp.tornado_settings={ \'headers\': { \'Content-Security-Policy\': \'frame-ancestors \\"self\\" ' + path + '\' } }']

The error that I am seeing on some machines is the following:
 

[C 11:51:12.011 NotebookApp] The 'tornado_settings' trait of a NotebookApp instance must be a dict, but a value of class 'str' (i.e. '{ \'headers\': {\'Content-Security-Policy\': \'frame-ancestors \\"self\\" Some\User\Path\' } }') was specified.


I do understand that it doesn't like the fact that it received a string instead of a dict, but I don't understand why the same code works only on some machines and fails on others.

If there's a programmatic way of passing such configurations instead of modifying the jupyter_notebook_config.py file, it would be ideal as I don't want to overwrite the config file every time.

Thanks in advance for your help!
Young

Young Park

unread,
Aug 17, 2017, 5:36:43 PM8/17/17
to Project Jupyter
Never mind. Found a solution!
Reply all
Reply to author
Forward
0 new messages