Example #1
0
def run_server(python_path, port=5008, show=False):
    commands = [
        'bokeh', 'server',
        '--port %i' % port,
        '--allow-websocket-origin=10.252.98.245:%i' % port, python_path
    ]
    main(commands)
Example #2
0
    def run(dirname):
        with WorkingDir(dirname):
            main(["bokeh", "png", "scatter1.py", "scatter2.py", "scatter3.py"])
        out, err = capsys.readouterr()
        assert err == ""
        assert out == ""

        assert set(["scatter1.png", "scatter2.png", "scatter3.png", "scatter1.py", "scatter2.py", "scatter3.py"]) == set(os.listdir(dirname))
Example #3
0
    def run(dirname: str) -> None:
        with WorkingDir(dirname):
            main(["bokeh", "json", "scatter.py"])
        out, err = capsys.readouterr()
        assert err == ""
        assert out == ""

        assert {"scatter.json", "scatter.py"} == set(os.listdir(dirname))
Example #4
0
    def run(dirname):
        with WorkingDir(dirname):
            main(["bokeh", "svg", "scatter.py"])
        out, err = capsys.readouterr()
        assert err == ""
        assert out == ""

        assert set(["scatter.svg", "scatter.py"]) == set(os.listdir(dirname))
Example #5
0
    def run(dirname):
        with WorkingDir(dirname):
            main(["bokeh", "json", "--output", "foo.json", "scatter.py"])
        out, err = capsys.readouterr()
        assert err == ""
        assert out == ""

        assert {"foo.json", "scatter.py"} == set(os.listdir(dirname))
Example #6
0
    def run(dirname):
        with WorkingDir(dirname):
            main(["bokeh", "svg", "scatter.py", "--output", "foo.svg"])
        out, err = capsys.readouterr()
        assert err == ""
        assert out == ""

        assert set(["foo.svg", "foo_1.svg", "scatter.py"]) == set(os.listdir(dirname))
Example #7
0
    def run(dirname):
        with WorkingDir(dirname):
            main(["bokeh", "html", "scatter.py", "--output", "foo.html"])
        out, err = capsys.readouterr()
        assert err == ""
        assert out == ""

        assert set(["foo.html", "scatter.py"]) == set(os.listdir(dirname))
Example #8
0
    def run(dirname):
        with WorkingDir(dirname):
            main(["bokeh", "png", "--output", "-", "scatter.py"])
        out, err = capsysbinary.readouterr()
        assert len(err) == 0
        assert len(out) > 0
        assert out.startswith(b'\x89PNG')

        assert set(["scatter.py"]) == set(os.listdir(dirname))
Example #9
0
    def run(dirname):
        with WorkingDir(dirname):
            main(["bokeh", "png", "--output", "-", "scatter.py"])
        out, err = capsysbinary.readouterr()
        assert len(err) == 0
        assert len(out) > 0
        assert out.startswith(b'\x89PNG')

        assert set(["scatter.py"]) == set(os.listdir(dirname))
Example #10
0
    def run(dirname):
        with WorkingDir(dirname):
            main(["bokeh", "svg", "--output", "-", "scatter.py"])
        out, err = capsys.readouterr()
        assert len(err) == 0
        assert len(out) > 0
        assert out.startswith('<svg version=')

        assert set(["scatter.py"]) == set(os.listdir(dirname))
Example #11
0
    def run(dirname):
        with WorkingDir(dirname):
            main(["bokeh", "svg", "--output", "-", "scatter.py"])
        out, err = capsys.readouterr()
        assert len(err) == 0
        assert len(out) > 0
        assert out.startswith('<svg version=')

        assert set(["scatter.py"]) == set(os.listdir(dirname))
Example #12
0
def test_error(capsys):
    from bokeh.command.subcommands.info import Info
    old_invoke = Info.invoke
    def err(x, y): raise RuntimeError("foo")
    Info.invoke = err
    with pytest.raises(SystemExit):
        main(["bokeh", "info"])
    out, err = capsys.readouterr()
    assert err == 'ERROR: foo\n'
    Info.invoke = old_invoke
Example #13
0
    def run(dirname):
        with WorkingDir(dirname):
            main(["bokeh", "html", "--show", "scatter.py"])
        out, err = capsys.readouterr()
        assert err == ""
        assert out == ""

        assert set(["scatter.html", "scatter.py"]) == set(os.listdir(dirname))
        assert mock_view.called
        assert mock_view.call_args[0] == ('scatter.html',)
Example #14
0
    def run(dirname):
        with WorkingDir(dirname):
            main(["bokeh", "html", "--show", "scatter.py"])
        out, err = capsys.readouterr()
        assert err == ""
        assert out == ""

        assert set(["scatter.html", "scatter.py"]) == set(os.listdir(dirname))
        assert mock_view.called
        assert mock_view.call_args[0] == ('scatter.html', )
Example #15
0
def test_error(capsys):
    from bokeh.command.subcommands.info import Info
    old_invoke = Info.invoke
    def err(x, y): raise RuntimeError("foo")
    Info.invoke = err
    with pytest.raises(SystemExit):
        main(["bokeh", "info"])
    out, err = capsys.readouterr()
    assert err == 'ERROR: foo\n'
    Info.invoke = old_invoke
Example #16
0
def test_run(capsys):
    main(["bokeh", "info"])
    out, err = capsys.readouterr()
    lines = out.split("\n")
    assert len(lines) == 5
    assert lines[0].startswith("Python version")
    assert lines[1].startswith("IPython version")
    assert lines[2].startswith("Bokeh version")
    assert lines[3].startswith("BokehJS static")
    assert lines[4] == ""
    assert err == ""
Example #17
0
def test_run(capsys):
    main(["bokeh", "info"])
    out, err = capsys.readouterr()
    lines = out.split("\n")
    assert len(lines) == 5
    assert lines[0].startswith("Python version")
    assert lines[1].startswith("IPython version")
    assert lines[2].startswith("Bokeh version")
    assert lines[3].startswith("BokehJS static")
    assert lines[4] == ""
    assert err == ""
Example #18
0
def test_no_script(capsys) -> None:
    with (TmpDir(prefix="bokeh-json-no-script")) as dirname:
        with WorkingDir(dirname):
            with pytest.raises(SystemExit):
                main(["bokeh", "json"])
        out, err = capsys.readouterr()
        too_few = "the following arguments are required: DIRECTORY-OR-SCRIPT"
        assert err == """usage: bokeh json [-h] [--indent LEVEL] [-o FILENAME] [--args ...]
                  DIRECTORY-OR-SCRIPT [DIRECTORY-OR-SCRIPT ...]
bokeh json: error: %s
""" % (too_few)
        assert out == ""
Example #19
0
def test_no_script(capsys):
    with (TmpDir(prefix="bokeh-png-no-script")) as dirname:
        with WorkingDir(dirname):
            with pytest.raises(SystemExit):
                main(["bokeh", "png"])
        out, err = capsys.readouterr()
        too_few = "the following arguments are required: DIRECTORY-OR-SCRIPT"
        assert err == """usage: bokeh png [-h] [--height HEIGHT] [--width WIDTH] [-o FILENAME]
                 [--args ...]
                 DIRECTORY-OR-SCRIPT [DIRECTORY-OR-SCRIPT ...]
bokeh png: error: %s
""" % (too_few)
        assert out == ""
Example #20
0
def plot(show=False, port=None):
    """ run Bokeh server
    """
    logging.info("emonitor plot")
    cmd = ["bokeh", "serve"]
    if show:
        cmd.append("--show")
    if port is not None:
        cmd.append("--port")
        cmd.append(str(port))
    cmd.append(LIVE)
    cmd.append(HISTORY)
    main(cmd)
Example #21
0
def test_run(capsys) -> None:
    main(["bokeh", "info"])
    out, err = capsys.readouterr()
    lines = out.split("\n")
    assert len(lines) == 8
    assert lines[0].startswith("Python version")
    assert lines[1].startswith("IPython version")
    assert lines[2].startswith("Tornado version")
    assert lines[3].startswith("Bokeh version")
    assert lines[4].startswith("BokehJS static")
    assert lines[5].startswith("node.js version")
    assert lines[6].startswith("npm version")
    assert lines[7] == ""
    assert err == ""
Example #22
0
def test_no_script(capsys):
    with (TmpDir(prefix="bokeh-html-no-script")) as dirname:
        with WorkingDir(dirname):
            with pytest.raises(SystemExit):
                main(["bokeh", "html"])
        out, err = capsys.readouterr()
        if is_python2:
            too_few = "too few arguments"
        else:
            too_few = "the following arguments are required: DIRECTORY-OR-SCRIPT"
        assert err == """usage: bokeh html [-h] [--show] [-o FILENAME] [--args ...]
                  DIRECTORY-OR-SCRIPT [DIRECTORY-OR-SCRIPT ...]
bokeh html: error: %s
""" % (too_few)
        assert out == ""
Example #23
0
def test_no_script(capsys):
    with (TmpDir(prefix="bokeh-png-no-script")) as dirname:
        with WorkingDir(dirname):
            with pytest.raises(SystemExit):
                main(["bokeh", "png"])
        out, err = capsys.readouterr()
        if six.PY2:
            too_few = "too few arguments"
        else:
            too_few = "the following arguments are required: DIRECTORY-OR-SCRIPT"
        assert err == """usage: bokeh png [-h] [--height HEIGHT] [--width WIDTH] [-o FILENAME]
                 [--args ...]
                 DIRECTORY-OR-SCRIPT [DIRECTORY-OR-SCRIPT ...]
bokeh png: error: %s
""" % (too_few)
        assert out == ""
Example #24
0
def DataExplorer_open(DatEx_df, data_name='TRNSYS Results', port=80,
                      bokeh_app=r'C:\Users\nettelstroth\Documents' +
                                r'\07 Python\dataexplorer',
                      show=True, output_backend='webgl', mark_index=True):
    """Open the given DataFrame in the DataExplorer application.

    TRNpy and DataExplorer are a great combination, because the values of
    parametric runs can be viewed and filtered as classes in the DataExplorer.
    """
    # Mark index column names as classifications
    if mark_index:
        DatEx_df = DataExplorer_mark_index(DatEx_df)

    # Prepare settings:
    data_file = os.path.join(bokeh_app, 'upload', data_name + '.xlsx')
    logger.info('Saving file for DataExplorer... ')
    logger.info(data_file)
    if logger.isEnabledFor(logging.INFO):
        print(DatEx_df.head())

    # Save this as a file that DataExplorer will load again
    DatEx_df.to_excel(data_file, merge_cells=False)

    logger.info('Starting DataExplorer...')

    port_blocked = True
    while port_blocked:
        call_list = ["bokeh", "serve", bokeh_app, "--port", str(port)]
        if show:
            call_list.append("--show")
        call_list += ["--args",
                      "--name", data_name,
                      "--file", data_file,
                      "--bokeh_output_backend", output_backend]
        try:
            main(call_list)  # Call Bokeh app
        except SystemExit:
            # Error would produce ugly print (when port is already in use)
            port += 1  # Increment port number for the next try
        else:  # try was successful, no SystemExit was raised
            port_blocked = False
def test_no_subcommand(capsys):
    with pytest.raises(SystemExit):
        main(["bokeh"])
    out, err = capsys.readouterr()
    assert err == "ERROR: Must specify subcommand, one of: html, info, json, png, sampledata, secret, serve, static or svg\n"
    assert out == ""
def test_version_short(capsys):
    with pytest.raises(SystemExit):
        main(["bokeh", "-v"])
    _assert_version_output(capsys)
Example #27
0
def test_run(capsys):
    main(["bokeh", "sampledata"])
    assert did_call_download == True
Example #28
0
def go():
    check_python_3()
    main()
Example #29
0
def test_run(capsys):
    main(["bokeh", "sampledata"])
    assert did_call_download == True
Example #30
0
def test_version_short(capsys):
    with pytest.raises(SystemExit):
        main(["bokeh", "-v"])
    _assert_version_output(capsys)
Example #31
0
def bokeh_main(args):
    from bokeh.command.bootstrap import main
    main(args)
Example #32
0
def test_run_static(capsys):
    main(["bokeh", "info", "--static"])
    out, err = capsys.readouterr()
    assert err == ""
    assert out.endswith('/bokeh/server/static\n')
Example #33
0
def test_no_subcommand(capsys):
    with pytest.raises(SystemExit):
        main(["bokeh"])
    out, err = capsys.readouterr()
    assert err == "ERROR: Must specify subcommand, one of: html, json or serve\n"
    assert out == ""
Example #34
0
def test_no_subcommand(capsys) -> None:
    with pytest.raises(SystemExit):
        main(["bokeh"])
    out, err = capsys.readouterr()
    assert err == "ERROR: Must specify subcommand, one of: build, info, init, json, sampledata, secret, serve or static\n"
    assert out == ""
Example #35
0
def test_run(capsys):
    main(["bokeh", "secret"])
    out, err = capsys.readouterr()
    assert err == ""
    assert len(out) == 45
    assert out[-1] == '\n'
Example #36
0
python_interpreter_path = sys.executable
bin_dir = os.path.dirname(python_interpreter_path)
node_path = os.path.join(bin_dir, "node")
os.environ['BOKEH_NODEJS_PATH'] = node_path
base_dir = os.path.dirname(os.path.abspath(__file__))
sample_dir = os.path.join(base_dir, "../embedding/deep/my_django_bokeh_site/djangobokeh/bokeh_apps/")
sliders_path = os.path.join(sample_dir, "sliders.py")
nyc_pickup_path = os.path.join(sample_dir, "nyc_pickup.py")
sys.argv.append("serve")

if TEST_APP == "sliders":
    sys.argv.append(sliders_path)
elif TEST_APP == "nyc_pickup":
    nyc_pickup_data_path = os.path.join(sample_dir, "data", "nyc_taxi_wide.parq")
    if not os.path.isfile(nyc_pickup_data_path):
        print('!' * 30)
        print("Download sample data nyc_taxi_wide.parq at https://s3.amazonaws.com/datashader-data/nyc_taxi_wide.parq")
        print("Put it in folder 'embedding/deep/my_django_bokeh_site/djangobokeh/bokeh_apps/data/'")
        print("And try to run this script again")
        print('!' * 30)
        exit(1)
    sys.argv.append(nyc_pickup_path)

sys.argv.append("--allow-websocket-origin=127.0.0.1:5006")
sys.argv.append("--allow-websocket-origin=localhost:5006")
print(sys.argv)

# Main entry point
main(sys.argv)
Example #37
0
def test_no_subcommand(capsys):
    with pytest.raises(SystemExit):
        main(["bokeh"])
    out, err = capsys.readouterr()
    assert err == "ERROR: Must specify subcommand, one of: html, info, json, secret or serve\n"
    assert out == ""
Example #38
0
def bokeh_main(args):
    from bokeh.command.bootstrap import main
    main(args)
Example #39
0
def test_run(capsys):
    main(["bokeh", "secret"])
    out, err = capsys.readouterr()
    assert err == ""
    assert len(out) == 45
    assert out[-1] == '\n'
Example #40
0
import sys

from bokeh.command.bootstrap import main

main(sys.argv)
Example #41
0
widget = widgetbox(children=[
    num_tokens, sel_yaxis, sel_xaxis, sel_plot, add_row, stats_table
])
# ------------------------------------------------------------------------------

# Create widgetbox for individual analysis
widget1 = widgetbox(children=[inp_id])
# ------------------------------------------------------------------------------

# Safe plot to Initiate it within layout variable
plot = create_plot()
pie = create_pie()
box = create_boxplot()
# ------------------------------------------------------------------------------

# Define layout of the application
l = row(desc)
layout = row(widget, plot, box)
indv = row(widget1, pie, sh_ess)
# ------------------------------------------------------------------------------

# Add layout to output document
# Set title in navigation bar
curdoc().add_root(l)
curdoc().add_root(layout)
curdoc().add_root(indv)
curdoc().title = 'Comparative Visualizations of Essays'

if __name__ == '__main__':
    main(['bokeh', 'serve', '--show', 'main.py'])
Example #42
0
def test_run_static(capsys):
    main(["bokeh", "info", "--static"])
    out, err = capsys.readouterr()
    assert err == ""
    assert out.endswith(join('bokeh', 'server', 'static') + '\n')
def test_run(capsys: Capture) -> None:
    main(["bokeh", "sampledata"])
    assert did_call_download == True
Example #44
0
def test_version(capsys) -> None:
    with pytest.raises(SystemExit):
        main(["bokeh", "--version"])
    _assert_version_output(capsys)
Example #45
0
def test_run_static(capsys) -> None:
    main(["bokeh", "info", "--static"])
    out, err = capsys.readouterr()
    assert err == ""
    assert out.endswith(join('bokeh', 'server', 'static') + '\n')
Example #46
0
# RacePi is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# RacePi is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with RacePi.  If not, see <http://www.gnu.org/licenses/>.

import logo
from sys import argv
from os.path import dirname
from bokeh.command.bootstrap import main

d = dirname(argv[0])
args = [
    argv[0], 'serve', '--host', "*:5006", '--allow-websocket-origin', "*:5006",
    d
]

main(args)

# profiling example

#from cProfile import run
#run('main(args)', sort='tottime')
Example #47
0
def go():
    check_python_3()
    main()