How to change path of show()

I am trying to make show() work from WSL

I can get it to pop the browser after setting the BROWSER environment variable in .bashrc to my browser on windows.

However the link is file:///tmp/tempfile.html

And indeed in bash the html file is under /tmp/tempfile.html

But it throws an error because that’s not the correct path to reference from windows.

To reference the file in bash with the windows path I need:

file:///C:/Users/%MYUSERNAME%/AppData/Local/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/tmp/tempfile.html

Is there a way to specify the path show() should use?

Thanks,

Sébastien

I should add that I could not do that by specifying the file with output_file()

if I am in ‘C:/path/to/folder’

Then when running python in bash the path is /mnt/c/path/to/folder

So if I use output_file(“file.html”) the html file will indeed be in:

windows path : C:/path/to/folder/file.html

bash path: /mnt/c/path/to/folder/file.html

But the path in the browser after calling show() will be the bash path, when I need it to be the windows path

Hi,

I don’t know anything about WSL, so not sure if this is something we can accommodate or work around or not. But “show” is a thin and simple wrapper around “view”:

[https://github.com/bokeh/bokeh/blob/master/bokeh/util/browser.py#L53](https://github.com/bokeh/bokeh/blob/master/bokeh/util/browser.py#L53)

Which itself is a thin wrapper around the standard library “webbrowser” module. If you know the correct location, I’d suggest using either one of those directly.

Thanks,

Bryan

···

On Jul 13, 2018, at 17:24, Sébastien Roche [email protected] wrote:

I should add that I could not do that by specifying the file with output_file()

if I am in ‘C:/path/to/folder’

Then when running python in bash the path is /mnt/c/path/to/folder

So if I use output_file(“file.html”) the html file will indeed be in:

windows path : C:/path/to/folder/file.html

bash path: /mnt/c/path/to/folder/file.html

But the path in the browser after calling show() will be the bash path, when I need it to be the windows path

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/d15c2bec-0ef3-4b75-8527-1ab9d6bf414a%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Thank you !

Seems like in I would just need to change the filename just after it has been saved in this function

def _show_file_with_state(obj, state, new, controller):
    '''

    '''
    filename = save(obj, state=state)
    controller.open("file://" + filename, new=NEW_PARAM[new])
···

Le vendredi 13 juillet 2018 18:29:40 UTC-4, Bryan Van de ven a écrit :

Hi,

I don’t know anything about WSL, so not sure if this is something we can accommodate or work around or not. But “show” is a thin and simple wrapper around “view”:

https://github.com/bokeh/bokeh/blob/master/bokeh/util/browser.py#L53

Which itself is a thin wrapper around the standard library “webbrowser” module. If you know the correct location, I’d suggest using either one of those directly.

Thanks,

Bryan

On Jul 13, 2018, at 17:24, Sébastien Roche [email protected] wrote:

I should add that I could not do that by specifying the file with output_file()

if I am in ‘C:/path/to/folder’

Then when running python in bash the path is /mnt/c/path/to/folder

So if I use output_file(“file.html”) the html file will indeed be in:

windows path : C:/path/to/folder/file.html

bash path: /mnt/c/path/to/folder/file.html

But the path in the browser after calling show() will be the bash path, when I need it to be the windows path

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/d15c2bec-0ef3-4b75-8527-1ab9d6bf414a%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Yes, basically, If there is a way to provide the correct filename in WSL, a PR would be welcome.

Thanks,

Bryan

···

On Jul 13, 2018, at 17:50, Sébastien Roche [email protected] wrote:

Thank you !

Seems like in I would just need to change the filename just after it has been saved in this function

def _show_file_with_state(obj, state, new, controller):
    '''

    '''
    filename = save(obj, state=state)
    controller.open("file://" + filename, new=NEW_PARAM[new])

Le vendredi 13 juillet 2018 18:29:40 UTC-4, Bryan Van de ven a écrit :

Hi,

I don’t know anything about WSL, so not sure if this is something we can accommodate or work around or not. But “show” is a thin and simple wrapper around “view”:

[https://github.com/bokeh/bokeh/blob/master/bokeh/util/browser.py#L53](https://github.com/bokeh/bokeh/blob/master/bokeh/util/browser.py#L53)

Which itself is a thin wrapper around the standard library “webbrowser” module. If you know the correct location, I’d suggest using either one of those directly.

Thanks,

Bryan

On Jul 13, 2018, at 17:24, Sébastien Roche [email protected] wrote:

I should add that I could not do that by specifying the file with output_file()

if I am in ‘C:/path/to/folder’

Then when running python in bash the path is /mnt/c/path/to/folder

So if I use output_file(“file.html”) the html file will indeed be in:

windows path : C:/path/to/folder/file.html

bash path: /mnt/c/path/to/folder/file.html

But the path in the browser after calling show() will be the bash path, when I need it to be the windows path

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/d15c2bec-0ef3-4b75-8527-1ab9d6bf414a%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/edb1509f-3fea-4fdf-ba49-52abb8dfc739%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

I could not find a way to systematically have the correct paths in all possible cases.

I think the best is to use custom paths and translate them “manually”:

from bokeh.io import output_file,save
from bokeh.util.browser import get_browser_controller
from bokeh.models import Div

bash_path = ‘/mnt/c/users/public/test.html’
windows_path = ‘c:/users/public/test.html’

output_file(bash_path)
save(Div(text=‘Hello’))
controller = get_browser_controller() # works if the BROWSER environment variable is set
controller.open(‘file://’+windows_path)

``

···

Le vendredi 13 juillet 2018 19:02:34 UTC-4, Bryan Van de ven a écrit :

Yes, basically, If there is a way to provide the correct filename in WSL, a PR would be welcome.

Thanks,

Bryan

On Jul 13, 2018, at 17:50, Sébastien Roche [email protected] wrote:

Thank you !

Seems like in I would just need to change the filename just after it has been saved in this function

def _show_file_with_state(obj, state, new, controller):
    '''

    '''
    filename = save(obj, state=state)
    controller.open("file://" + filename, new=NEW_PARAM[new])

Le vendredi 13 juillet 2018 18:29:40 UTC-4, Bryan Van de ven a écrit :

Hi,

I don’t know anything about WSL, so not sure if this is something we can accommodate or work around or not. But “show” is a thin and simple wrapper around “view”:

[https://github.com/bokeh/bokeh/blob/master/bokeh/util/browser.py#L53](https://github.com/bokeh/bokeh/blob/master/bokeh/util/browser.py#L53)

Which itself is a thin wrapper around the standard library “webbrowser” module. If you know the correct location, I’d suggest using either one of those directly.

Thanks,

Bryan

On Jul 13, 2018, at 17:24, Sébastien Roche [email protected] wrote:

I should add that I could not do that by specifying the file with output_file()

if I am in ‘C:/path/to/folder’

Then when running python in bash the path is /mnt/c/path/to/folder

So if I use output_file(“file.html”) the html file will indeed be in:

windows path : C:/path/to/folder/file.html

bash path: /mnt/c/path/to/folder/file.html

But the path in the browser after calling show() will be the bash path, when I need it to be the windows path

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/d15c2bec-0ef3-4b75-8527-1ab9d6bf414a%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/edb1509f-3fea-4fdf-ba49-52abb8dfc739%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.