takluyver/nbopen

root directory for notebook server

Closed this issue · 4 comments

How does nbopen determine if the current notebook file (.ipynb) can be opened in the current notebook server?

e.g. if I have 2 notebook servers opened in 2 directories, can nbopen find whether to launch a third server when opening a new notebook with nbopen command or from explorer?

The issue is that notebook server may not have access to a new notebook, if it is not located in one of its sub-directories.

It checks whether the any running server was started in a path that's a prefix of the current notebook path. E.g. if I have a server running in /home/thomas and I try to open /home/thomas/foo/bar.ipynb, it will use the existing server. But if I try to open /opt/baz.ipynb, it will start a new server.

Well, I got an error on Windows this afternoon, but this is working on
Linux. Let me check tomorrow morning again. Maybe my mistake with the paths
or something.

On Tue, Nov 15, 2016 at 12:05 AM, Thomas Kluyver notifications@github.com
wrote:

It checks whether the any running server was started in a path that's a
prefix of the current notebook path. E.g. if I have a server running in
/home/thomas and I try to open /home/thomas/foo/bar.ipynb, it will use
the existing server. But if I try to open /opt/baz.ipynb, it will start a
new server.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#38 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AHgZ5ZPg30z-Gfj00mdae39424-oRBDqks5q-UuxgaJpZM4KyI0I
.

There may be a bug because I'm used to case-sensitive Linux paths, and Windows paths are case-insensitive.

I spent quite some time debugging and fixing this problem only to find this pull request which fixes the issue in the master:

#42

My solution is based on notebookapp, but is essentially the same:

        relpath = os.path.relpath(filename, start=server_inf['notebook_dir'])
        # based on "start" method in notebookapp
        uri = url_escape(url_path_join('notebooks', *relpath.split(os.sep)))
        url = url_path_join(server_inf['url'], uri)