bokeh.command.util¶
Provide utility functions for implementing the bokeh
command.
-
build_single_handler_application
(path, argv=None)[source]¶ Return a Bokeh application built using a single handler for a script, notebook, or directory.
In general a Bokeh
Application
may have any number of handlers to initializeDocument
objects for new client sessions. However, in many cases only a single handler is needed. This function examines thepath
provided, and returns anApplication
initialized with one of the following handlers:ScriptHandler
whenpath
is to a.py
script.NotebookHandler
whenpath
is to an.ipynb
Jupyter notebook.DirectoryHandler
whenpath
is to a directory containing amain.py
script.
Parameters: Returns: Raises: RuntimeError
Notes
If
path
ends with a filemain.py
then a warning will be printed regarding running directory-style apps by passing the directory instead.
-
build_single_handler_applications
(paths, argvs=None)[source]¶ Return a dictionary mapping routes to Bokeh applications built using single handlers, for specified files or directories.
This function iterates over
paths
andargvs
and callsbuild_single_handler_application()
on each to generate the mapping.Parameters: Returns: dict[str, Application]
Raises: RuntimeError
-
die
(message, status=1)[source]¶ Print an error message and exit.
This function will call
sys.exit
with the givenstatus
and the process will terminate.Parameters:
-
report_server_init_errors
(address=None, port=None, **kwargs)[source]¶ A context manager to help print more informative error messages when a
Server
cannot be started due to a network problem.Parameters: Example
with report_server_init_errors(**server_kwargs): server = Server(applications, **server_kwargs)
If there are any errors (e.g. port or address in already in use) then a critical error will be logged and the process will terminate with a call to
sys.exit(1)