evtdb - CSTBox Events Database access D-Bus service¶
CSTBox Events Database access D-Bus service.
The class defined in this module do not implement the data access layer, but sits on top of it to provide a generic API for data storage and retrieval.
The data access layer is defined in separate DAO classes, which can be viewed as drivers for supported persistence mechanism. This approach allows switching between different underlying storage strategies, without any impact for the upper layers.
The concrete DAO to be used must be passed to the constructor.
-
class
pycstbox.evtdb.
EventsDatabase
(conn, daos)¶ CSTBox Event database service.
This container will host a service object for each event channel, in order to keep the various communication separated, and this easing the subscription to a given kind of channel.
Parameters: - conn – the D-Bus connection (Session, System,...)
- daos – a list of tuples, containing the channel name and the DAO instance managing its events
-
class
pycstbox.evtdb.
EventDatabaseObject
(channel, dao)¶ The service object for a given event database.
One instance of this class is created for managing the persistence of each event channel to be managed (see EventDatabase.__init__().
Parameters: channel (str) – the event channel -
start
()¶ Service objet runtime initialization
-
stop
()¶ Cleanup before stop
-
get_available_days
()¶ Returns the list of days for which events have been stored.
The result is an array of dates formatted as “YYYY-MM-DD”
-
get_events_for_day
(day, var_type=None, var_name=None)¶ Returns the list of events matching the provided criteria.
The result is an array of tuples representing the properties of the events (timestamp, var_type, var_name, value, dictionary of additional infos).
Events are returned in D-Bus compatible format
Parameters: - day (str) – the date of the requested days (as a valid SQL date)
- var_type (str) – (optional) an event class (‘temperature’,...) for filtering the returned list
- var_name (str) – (optional) the var_name of events for filtering the returned list
Returns: a list of events, as serializable tuples
-
get_events
(event_filter)¶ Returns the list of events matching the provided filter.
Events are returned in D-Bus compatible format
Parameters: event_filter (dict) – DAOs get_events() method keyword parameters as a dictonary Returns: a list of events, as serializable tuples
-
-
pycstbox.evtdb.
get_object
(channel)¶ Returns the service proxy object for a given event channel if available
Parameters: channel (str) – the event channel managed by the requested service instance Returns: the requested service instance, if exists Raises ValueError: if no bus name match the requested channel