How to use the dtale.utils.build_url function in dtale

To help you get started, we’ve selected a few dtale examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github man-group / dtale / tests / dtale / test_utils.py View on Github external
def test_build_url():
    assert utils.build_url(8080, 'localhost') == 'http://localhost:8080'
    assert utils.build_url(8080, 'http://localhost') == 'http://localhost:8080'
    assert utils.build_url(8080, 'https://localhost') == 'https://localhost:8080'
github man-group / dtale / tests / dtale / test_utils.py View on Github external
def test_build_url():
    assert utils.build_url(8080, 'localhost') == 'http://localhost:8080'
    assert utils.build_url(8080, 'http://localhost') == 'http://localhost:8080'
    assert utils.build_url(8080, 'https://localhost') == 'https://localhost:8080'
github man-group / dtale / tests / dtale / test_utils.py View on Github external
def test_build_url():
    assert utils.build_url(8080, 'localhost') == 'http://localhost:8080'
    assert utils.build_url(8080, 'http://localhost') == 'http://localhost:8080'
    assert utils.build_url(8080, 'https://localhost') == 'https://localhost:8080'
github man-group / dtale / dtale / app.py View on Github external
:Example:

        >>> import dtale
        >>> import pandas as pd
        >>> df = pandas.DataFrame([dict(a=1,b=2,c=3)])
        >>> dtale.show(df)
        D-Tale started at: http://hostname:port

        ..link displayed in logging can be copied and pasted into any browser
    """

    logfile, log_level, verbose = map(kwargs.get, ['logfile', 'log_level', 'verbose'])
    setup_logging(logfile, log_level or 'info', verbose)

    initialize_process_props(host, port, force)
    url = build_url(ACTIVE_PORT, ACTIVE_HOST)
    instance = startup(url, data=data, data_loader=data_loader, name=name)
    is_active = not running_with_flask_debug() and is_up(url)
    if is_active:
        def _start():
            if open_browser:
                instance.open_browser()
    else:
        def _start():
            app = build_app(url, reaper_on=reaper_on, host=ACTIVE_HOST)
            if debug:
                app.jinja_env.auto_reload = True
                app.config['TEMPLATES_AUTO_RELOAD'] = True
            else:
                getLogger("werkzeug").setLevel(LOG_ERROR)

            if open_browser:
github man-group / dtale / dtale / app.py View on Github external
:param host: hostname to use otherwise it will default to the output of :func:`python:socket.gethostname`
    :type host: str, optional
    :param port: port to use otherwise default to the output of :func:dtale.app.find_free_port
    :type port: str, optional
    :param force: boolean flag to determine whether to ignore the :func:dtale.app.find_free_port function
    :type force: bool
    :return:
    """
    global ACTIVE_HOST, ACTIVE_PORT

    if force:
        active_host = get_host(ACTIVE_HOST)
        curr_base = build_url(ACTIVE_PORT, active_host)
        final_host = get_host(host)
        new_base = build_url(port, final_host)
        if curr_base != new_base:
            if is_up(new_base):
                try:
                    kill(new_base)  # kill the original process
                except BaseException:
                    raise IOError((
                        'Could not kill process at {}, possibly something else is running at port {}. Please try '
                        'another port.'
                    ).format(new_base, port))
                while is_up(new_base):
                    time.sleep(0.01)
            ACTIVE_HOST = final_host
            ACTIVE_PORT = port
            return

    if ACTIVE_HOST is None:
github man-group / dtale / dtale / app.py View on Github external
Helper function to initalize global state corresponding to the host & port being used for your
    :class:`flask:flask.Flask` process

    :param host: hostname to use otherwise it will default to the output of :func:`python:socket.gethostname`
    :type host: str, optional
    :param port: port to use otherwise default to the output of :func:dtale.app.find_free_port
    :type port: str, optional
    :param force: boolean flag to determine whether to ignore the :func:dtale.app.find_free_port function
    :type force: bool
    :return:
    """
    global ACTIVE_HOST, ACTIVE_PORT

    if force:
        active_host = get_host(ACTIVE_HOST)
        curr_base = build_url(ACTIVE_PORT, active_host)
        final_host = get_host(host)
        new_base = build_url(port, final_host)
        if curr_base != new_base:
            if is_up(new_base):
                try:
                    kill(new_base)  # kill the original process
                except BaseException:
                    raise IOError((
                        'Could not kill process at {}, possibly something else is running at port {}. Please try '
                        'another port.'
                    ).format(new_base, port))
                while is_up(new_base):
                    time.sleep(0.01)
            ACTIVE_HOST = final_host
            ACTIVE_PORT = port
            return