[IPython-dev] Absolute Path IPython

Matthias Bussonnier bussonniermatthias at gmail.com
Tue Sep 23 05:41:51 EDT 2014


Hi lucien, 

Thanks for the explanation, I better understand what you want to do. 
You are trying do build something under some assumption that are wrong and cannot reliably always work. 

Let assume the following: 

	- I am on  my laptop (it does not have python installed)
	- the IPython notebook server is on my Desktop with an open port on the internet. 
	- My kernel were my code runs in on my lab cluster. 

Webbrower.open(url) is runned on the cluster, though the ipynb files are obviously on my desktop, and what you want is open a page on your laptop. So this cannot reliably work. It needs you to get information on the network architecture you might not have. 

That beeing said. You might be able to workaround by :

	- display html instead of trying web browser open 
	- avoid absolute url, use '/notebook/<path>'
	- have a look at nbopen[1] that does what you ask in **some** cases
	
You cannot get around the fact that you cannot access ../ url thing. It is a question of **security**. 

You project of having ipynb as documentation is interesting, we would be glad to see how you did it, and how it feels for users. 
We have a long term project in doing something alike, but not yet completely defined.

Thanks, 
-- 
M                                                             


[1]: https://github.com/takluyver/nbopen



Le 23 sept. 2014 à 10:46, Lucien Boillod a écrit :

> Hi,
> 
> Sorry if I didn’t explain as well my problem. I have my documentation inside a folder, into a predefined path that I can call with a command (vcsn.datadir), in function where you are (when you open your Ipython notebook) the function return the correct path to access to the doc.
> I would like to open some files in this folder ( this is .ipynb files) so I tried this :
> import webbrowser
> def doc(m):
>    url = 'localhost:8888' + vcsn.datadir + '/notebooks/algos/' + m + '.ipynb'
>    webbrowser.open(url)
> 
> doc(‘automaton.proper’)
> 
> But this isn’t work. Firstly because we are not obviously in the localhost 8888, it can be 8834 or whatever, but I don’t know how to catch the local host of our notebook session. Secondly because it seems not recognize this path, but if I go handly to this path there is the file, and I can open automaton.proper.ipynb.

> What I simply tried to say is we can’t go down repository when we open a notebook.
> Example we are in Documents/ and we open a new notebook. Now we can’t open a file which is before 
> Documents/ we only can hike the path from Documents/../.. and can’t ../../Documents. 


> 
> 
> Le 23 sept. 2014 à 09:43, Matthias Bussonnier <bussonniermatthias at gmail.com> a écrit :
> 
>> Hi Lucien, 
>> 
>> Can you give more context to what you are trying to achieve ? Like an example or a link to your project?
>> Usually you should be able to use absolute path in IPython to read files. 
>> 
>> Cheers,
>> -- 
>> M
>> 
>> Envoyé de mon iPhone
>> 
>>> Le 23 sept. 2014 à 09:27, Lucien Boillod <lucienboillod at gmail.com> a écrit :
>>> 
>>> Hello,
>>> 
>>> Why can we not do a absolute path to find or read some files ? This is really a inconvenience because I would like the user can access, anywhere he is, to the documentation installed in a folder into my project, but without he has to find the way. But I can’t implement a magic_command line like “doc”, that open the file “index.ipynb” which is installed inside the project in a predefined path, because it’s not all allow absolute PATH.
>>> So if you have a simple way to do my trick … 
>>> 
>>> Kindest regards
>>> _______________________________________________
>>> IPython-dev mailing list
>>> IPython-dev at scipy.org
>>> http://mail.scipy.org/mailman/listinfo/ipython-dev
>> _______________________________________________
>> IPython-dev mailing list
>> IPython-dev at scipy.org
>> http://mail.scipy.org/mailman/listinfo/ipython-dev
> 
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140923/80218f97/attachment.html>


More information about the IPython-dev mailing list