Ejemplo n.º 1
0
def show_session(session_id=None, url='default', app_path='/',
                 session=None, browser=None, new="tab", controller=None):
        """Open a browser displaying a session document.

        If you have a session from ``pull_session()`` or
        ``push_session`` you can ``show_session(session=mysession)``.
        If you don't need to open a connection to the server yourself,
        you can show a new session in a browser by providing just the
        ``url`` and ``app_path``.

        Args:

        session_id : string, optional
             The name of the session, None to autogenerate a random one (default: None)

        url : str, optional
             The base server URL to connect to (default: 'default')

        app_path : str, optional
             Relative path to the app on the server (defualt: '/')

        session (ClientSession, optional) : session to get session ID and server URL from
            If you specify this, you don't need to specify session_id and url

        browser (str, optional) : browser to show with (default: None)
            For systems that support it, the **browser** argument allows
            specifying which browser to display in, e.g. "safari", "firefox",
            "opera", "windows-default" (see the ``webbrowser`` module
            documentation in the standard lib for more details).

        new (str, optional) : new file output mode (default: "tab")
            For file-based output, opens or raises the browser window
            showing the current output file.  If **new** is 'tab', then
            opens a new tab. If **new** is 'window', then opens a new window.

        """

        if session is not None:
            server_url = server_url_for_websocket_url(session._connection.url)
            session_id = session.id
        else:
            coords = _SessionCoordinates(dict(session_id=session_id, url=url, app_path=app_path))
            server_url = coords.server_url
            session_id = coords.session_id

        if controller is None:
            import bokeh.browserlib as browserlib
            controller = browserlib.get_browser_controller(browser=browser)

        controller.open(server_url + "?bokeh-session-id=" + _encode_query_param(session_id),
                        new=_new_param[new])
Ejemplo n.º 2
0
def show_session(session_id=None,
                 server_url=None,
                 session=None,
                 browser=None,
                 new="tab",
                 controller=None):
    """ Open a browser displaying a session document.

        Args:

        session_id (str, optional) : session ID to open (default: DEFAULT_SESSION_ID)

        server_url (str, optional) : server base URL to open the session on (default: DEFAULT_HTTP_SERVER_URL)

        session (ClientSession, optional) : session to get session ID and server URL from
            If you specify this, you don't need to specify session_id and server_url

        browser (str, optional) : browser to show with (default: None)
            For systems that support it, the **browser** argument allows
            specifying which browser to display in, e.g. "safari", "firefox",
            "opera", "windows-default" (see the ``webbrowser`` module
            documentation in the standard lib for more details).

        new (str, optional) : new file output mode (default: "tab")
            For file-based output, opens or raises the browser window
            showing the current output file.  If **new** is 'tab', then
            opens a new tab. If **new** is 'window', then opens a new window.
        """

    if session_id is None:
        if session is not None:
            session_id = session.id
        else:
            session_id = DEFAULT_SESSION_ID

    if server_url is None:
        if session is not None:
            server_url = server_url_for_websocket_url(session._connection.url)
        else:
            server_url = DEFAULT_SERVER_HTTP_URL

    if controller is None:
        import bokeh.browserlib as browserlib
        controller = browserlib.get_browser_controller(browser=browser)

    controller.open(server_url + "?bokeh-session-id=" +
                    _encode_query_param(session_id),
                    new=_new_param[new])
Ejemplo n.º 3
0
def show_session(session_id=None, server_url=None,
                 session=None, browser=None, new="tab", controller=None):
        """ Open a browser displaying a session document.

        Args:

        session_id (str, optional) : session ID to open (default: DEFAULT_SESSION_ID)

        server_url (str, optional) : server base URL to open the session on (default: DEFAULT_HTTP_SERVER_URL)

        session (ClientSession, optional) : session to get session ID and server URL from
            If you specify this, you don't need to specify session_id and server_url

        browser (str, optional) : browser to show with (default: None)
            For systems that support it, the **browser** argument allows
            specifying which browser to display in, e.g. "safari", "firefox",
            "opera", "windows-default" (see the ``webbrowser`` module
            documentation in the standard lib for more details).

        new (str, optional) : new file output mode (default: "tab")
            For file-based output, opens or raises the browser window
            showing the current output file.  If **new** is 'tab', then
            opens a new tab. If **new** is 'window', then opens a new window.
        """

        if session_id is None:
            if session is not None:
                session_id = session.id
            else:
                session_id = DEFAULT_SESSION_ID

        if server_url is None:
            if session is not None:
                server_url = server_url_for_websocket_url(session._connection.url)
            else:
                server_url = DEFAULT_SERVER_HTTP_URL

        if controller is None:
            import bokeh.browserlib as browserlib
            controller = browserlib.get_browser_controller(browser=browser)

        controller.open(server_url + "?bokeh-session-id=" + _encode_query_param(session_id),
                        new=_new_param[new])