analytics package

Subpackages

Submodules

analytics.eventhandler module

Execute action when event occurs

class analytics.eventhandler.EventHandler(config_queue, config_file=None, redis_host='localhost', redis_port=6379, redis_stream='detection')

Bases: object

Event handler class

get_file_configuration(config_file)

Get Configuration from file

Returns:

an object with the file configuration

Return type:

Configuration

loop_events()

Execute enabled actions when receive a redis message

analytics.logger module

Service Logger

class analytics.logger.CustomFormatter(format_str)

Bases: Formatter

Custom formatter for logging

format(record)

Format the specified record as text.

The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.

class analytics.logger.Logger

Bases: object

This class contains the methods used to configure the service logger.

LOGGER_NAME = 'analytics'
classmethod get_logger()

Get logger with the given name

Returns:

A logger object

Return type:

logging

classmethod init(log_level=20, log_file: str = None)

initialize the service logger

Parameters:
  • log_level (optional) – Logging level as in logging. Defaults to logging.INFO.

  • log_file (str, optional) – Log file path. Defaults to None.

analytics.main module

Server entry point

analytics.main.main()

Main application

analytics.main.parse_args()

Parse arguments

analytics.server module

Base HTTP server using Flask.

class analytics.server.Server(controllers: list, host: str = '127.0.0.1', port: int = 5040)

Bases: object

Flask server

start()

Run the server with given port.

analytics.streamrecorder module

Stream recorder

class analytics.streamrecorder.StreamRecorder(vst_uri)

Bases: object

Stream recorder class.

Provides convenient functions to start VST’s recordings

record_event(sensor_id)

Starts event record for sensor

Parameters:

sensor_id (str) – The sensor ID from VST

Raise exception if request failed

Module contents