Anaconda Enterprise: Documentation

# bokeh.command.util

Provide utility functions for implementing the `bokeh` command.

`bokeh.command.util.``build_single_handler_application`(path, argv=None)

  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 initialize `Document` objects for new client sessions. However, in many cases only a single handler is needed. This function examines the `path` provided, and returns an `Application` initialized with one of the following handlers:

  - `ScriptHandler` when `path` is to a `.py` script.
  - `NotebookHandler` when `path` is to an `.ipynb` Jupyter notebook.
  - `DirectoryHandler` when `path` is to a directory containing a `main.py` script.

  Parameters: | path (str) – path to a file or directory for creating a Bokeh application. argv (seq[str], optional) – command line arguments to pass to the application handler
  Returns: | `Application`
  Raises: | `RuntimeError`

  Notes

  If `path` ends with a file `main.py` then a warning will be printed regarding running directory-style apps by passing the directory instead.

`bokeh.command.util.``build_single_handler_applications`(paths, argvs=None)

  Return a dictionary mapping routes to Bokeh applications built using single handlers, for specified files or directories.

  This function iterates over `paths` and `argvs` and calls `build_single_handler_application()` on each to generate the mapping.

  Parameters: | path (seq[str]) – paths to files or directories for creating Bokeh applications. argvs (dict[str, list[str]], optional) – mapping of paths to command line arguments to pass to the handler for each path
  Returns: | dict[str, Application]
  Raises: | `RuntimeError`

`bokeh.command.util.``die`(message, status=1)

  Print an error message and exit.

  This function will call `sys.exit` with the given `status` and the process will terminate.

  Parameters: | message (str) – error message to print status (int) – the exit status to pass to `sys.exit`

`bokeh.command.util.``report_server_init_errors`(*args, **kwds)

  A context manager to help print more informative error messages when a `Server` cannot be started due to a network problem.

  Parameters: | address (str) – network address that the server will be listening on port (int) – network address that the server will be listening on

  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)`