Brush

brush logo

A tool for logging and monitoring data from Menlo Systems optical frequency combs.

Installation

Brush is on PyPI:

$ pip install brush

Python versions of at least 3.3 are recommended, though Brush should work with Python 2.7 if necessary.

Data is stored using a SQL database. PostgresQL is recommended, but any database supported by SQLAlchemy will work.

Note

A database driver library will also need to be installed unless SQLite is used. See the SQLAlchemy dialect documentation for details.

Usage

Brush defines the following command-line options for collecting data:

  --config                         Path to configuration file (default
                                   ~/.brush.conf)
  --debug                          Enable debug output (default False)
  --offline                        Run in offline mode (default False)
  --redis-host                     Redis hostname (default localhost)
  --redis-password                 Redis password
  --redis-port                     Redis port (default 6379)
  --save-when-unlocked             Write data to database when comb is unlocked
                                   (default False)
  --server-port                    Port to serve on (default 8090)
  --server-url-prefix              URL prefix
  --sql-table                      SQL table name (default brush)
  --sql-url                        SQL database URL (default
                                   sqlite:///brush.sqlite)
  --xmlrpc-host                    XMLRPC server hostname
  --xmlrpc-password                XMLRPC server password
  --xmlrpc-port                    XMLRPC server port (default 8123)
  --xmlrpc-user                    XMLRPC server user


These can also be written into a configuration file. For example:

xmlrpc_host = "localhost"
xmlrpc_port = 8123
xmlrpc_user = None
xmlrpc_password = None

sql_url = "sqlite:///:memory:"

These values are just normal Python variables and will be overridden by any command-line options passed. See the Tornado documentation for additional details on configuration files.

To start logging data, say a brush.config file was created to store the Menlo server and SQL server details. Then Brush can be started with:

$ brush --config=brush.config

If using the default port, point your browser to http://localhost:8090 and see the current comb status.

HTTP API

Brush exposes the following routes for accessing data from the web interface and other programs:

GET /

Main page for displaying real-time data.

GET /data

Get data starting from the timestamp start up until the timestamp stop. Timestamps must be given in ISO 8601 format and passed as query arguments in the GET request.

If only start is given, the stop point is the current time.

Example:

http://localhost:8090/data?start=20160411T0900

Note

The database stores timestamps in UTC. It is up to the client to correctly account for this.

GET /data/current

Return the most recent data.

GET /data/recent

Return all data currently in the store.

GET /data/query/(.*)

Return the most recent value for the requested key.

GET /query/(.*)

Return the most recent value for the requested key.