[IPython-dev] custom JS and IPython.notebook.kernel usage (svn example)

epi massimodisasha at gmail.com
Wed Dec 5 05:42:24 EST 2012


Hi,


i'm used to have my "c.NotebookManager.notebook_dir" under version control, for now SVN … i should switch to GIT

i was playing with js in a custom.js file,  in order to add some "buttons"  to "COMMITT"  change to a notebook into my repository
(the plan was to add a custom toolbar to execute simple svn commands)

an example to store the results of svn info in a dict can be like :



		IPython.toolbar.add_buttons_group([
		    {
		         'label'   : 'SVN Info',
		         'icon'    : 'ui-icon-info', 
		         'callback': function(){IPython.notebook.kernel.execute('svninfolist = !svn info'),
				                        IPython.notebook.kernel.execute('svninfo = {}'),
				                        IPython.notebook.kernel.execute('for i in svninfolist[:-1]: j=i.split(":") ; svninfo[j[0]]=j[1].strip()')
										}
		    }
		    ]);

this give me a dict like :

2]:

svninfo
Out[2]:
{'Last Changed Author': 'epifanio',
 'Last Changed Date': '2012-11-20 15:30:34 -0500 (Tue, 20 Nov 2012)',
 'Last Changed Rev': '7847',
 'Node Kind': 'directory',
 'Path': '.',
 'Repository Root': 'https://myuser@myserver.org/svn',
 'Repository UUID': 'e8c77636-c7aa-4457-b6c1-051e789c14f2',
 'Revision': '7877',
 'Schedule': 'normal',
 'URL': 'https://myuser@myserver.org/svn/path/to/dir'
'}

while in order to "commit" changes, i was looking for something like :

- detect the name  for the "notebook" (filename.ipnb)

- clean all the output of the "notebook"

- save the "notebook"

- commit the saved file (here should prompt a js text input box where to add the commit notes, but i can live without it as a start)


		IPython.toolbar.add_buttons_group([
		    {
		         'label'   : 'Save & Commit Notebook',
		         'icon'    : 'ui-icon-circle-arrow-n', 
		         'callback': function(){IPython.notebook.kernel.execute('detect the notebook name'),
				                        IPython.notebook.kernel.execute('clean notebook'),
							IPython.notebook.kernel.execute('save notebook'),
							IPython.notebook.kernel.execute('svn commit notebook')}
		    }
		    ]);


i need an help to learn how to use "IPython.notebook.kernel.execute" from inside a JS code
i was looking in `docs/examples/widgets/directview` but i got lost :(

have you any hints on how can i use the ipython.notebook.kernel  in order to :

- print out some text in a new notebook cell 
- detect the name for the active notebook
- clear all the output for the active notebook


Thanks a lot for you help,

Massimo


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20121205/72763a20/attachment.html>


More information about the IPython-dev mailing list