datalogd package¶
The datalogd package contains the main DataLogDaemon,
plus the plugin base classes DataSource, DataFilter, and
DataSink, which must be extended to provide useful functionality.
The included data source/filter/sink plugins are contained separately in the
plugins package.
- class datalogd.DataFilter(sinks=[])[source]¶
Bases:
DataSource,DataSink,PluginThe base class for all data filter plugins.
DataFilters are subclasses of bothDataSources andDataSinks, thus are capable of both sending and receiving data. Typically, they are used to sit between aDataSourceand aDataSink(or otherDataFilters) in order to modify the data flowing between them in some way.
- class datalogd.DataLogDaemon(configfile=None, plugindirs=[], graph_dot=None)[source]¶
Bases:
objectThe main datalogd class.
The
DataLogDaemonreads configuration file(s), interprets the connection graph DOT specification, and initialises data source/filter/sink plugins and connections. Theasyncioevent loop must be started separately. For an example of this, see themain()method, which is the typical way the daemon is started.- Parameters:
configfile – Path to configuration file to load.
plugindirs – Directory, or list of directories from which to load additional plugins.
graph_dot – Connection graph specified in the DOT graph description language.
- class datalogd.DataSink[source]¶
Bases:
PluginThe base class for all data sink plugins.
DataSinks have areceive()method which accepts data from connectedDataSources.
- class datalogd.DataSource(sinks=[])[source]¶
Bases:
PluginThe base class for all data sink plugins.
DataSourceimplements methods for connecting or disconnecting sinks, and for sending data to connected sinks. It has no intrinsic functionality (it does not actually produce any data) and is not itself considered a plugin, so can’t be instantiated using the connection graph.- Parameters:
sinks –
DataSinkor list ofDataSinks to receive data produced by thisDataSource.
- connect_sinks(sinks)[source]¶
Register the provided
DataSinkas a receiver of data produced by thisDataSource. A list of sinks may also be provided.
- disconnect_sinks(sinks)[source]¶
Unregister the provided
DataSinkso that it no longer receives data produced by thisDataSource. A list of sinks may also be provided. It is not an error to provide a sink that is not currently connected.
- class datalogd.NullDataFilter(sinks=[])[source]¶
Bases:
DataFilterA
DataFilterwhich accepts data and passes it unchanged to any connectedDataSinks.
- class datalogd.NullDataSink[source]¶
Bases:
DataSinkA
DataSinkwhich accepts data and does nothing with it.Unlike the base
DataSink, this can be instantiated using the connection graph, although it provides no additional functionality.
- class datalogd.NullDataSource(sinks=[])[source]¶
Bases:
DataSourceA
DataSourcewhich produces no data.Unlike the base
DataSource, this can be instantiated using the connection graph, although it provides no additional functionality.
- datalogd.listify(value)[source]¶
Convert
valueinto a list.Modifies the behaviour of the python builtin
list()by accepting all types asvalue, not just iterables. Additionally, the behaviour of iterables is changed:list('str') == ['s', 't', 'r'], whilelistify('str') == ['str']list({'key': 'value'}) == ['key'], whilelistify({'key': 'value'}) == [{'key': 'value'}]
- Parameters:
value – Input value to convert to a list.
- Returns:
valueas a list.
- datalogd.main()[source]¶
Read command line parameters, instantiate a new
DataLogDaemonand begin execution of the event loop.
- datalogd.parse_dot_json(value)[source]¶
Interpret the value of a DOT attribute as JSON data.
DOT syntax requires double quotes around values which contain DOT punctuation (space, comma, {}, [] etc), and, if used, these quotes will also be present in the obtained value string. Unfortunately, JSON also uses double quotes for string values, which are then in conflict. This method will strip any double quotes from the passed
value, then will attempt to interpret as JSON after replacing single quotes with double quotes.Note that the use of this workaround means that single quotes must be used in any JSON data contained in the DOT attribute values.
Although not strictly correct JSON, some special values will be interpreted as their python equivalents. These are:
None or null (with any capitalisation) will be read as a python
None.True (with any capitalisation) will be read as a python
True.False (with any capitalisation) will be read as a python
False.NotImplemented (with any capitalisation) will be read as a python
NotImplemented.NaN (with any capitalisation) will be read as the python float
nan.Inf or Infinity (with any capitalisation) will be read as the python float
inf.-Inf or -Infinity (with any capitalisation) will be read as the python float
-inf.
- Parameters:
value – string to interpret.
- Returns:
value, possibly as a new type.
Subpackages¶
- datalogd.plugins package
- Submodules
- datalogd.plugins.aggregator_datafilter module
- datalogd.plugins.coolingpower_datafilter module
- datalogd.plugins.csv_datafilter module
- datalogd.plugins.file_datasink module
- datalogd.plugins.flowsensorcalibration_datafilter module
- datalogd.plugins.heartbeat_datasource module
- datalogd.plugins.influxdb2_datasink module
- datalogd.plugins.influxdb_datasink module
- datalogd.plugins.join_datafilter module
- datalogd.plugins.keyval_datafilter module
- datalogd.plugins.libsensors_datasource module
- datalogd.plugins.logging_datasink module
- datalogd.plugins.matplotlib_datasink module
- datalogd.plugins.picotc08_datasource module
- datalogd.plugins.polynomialfunction_datafilter module
- datalogd.plugins.print_datasink module
- datalogd.plugins.pyqtgraph_datasink module
- datalogd.plugins.randomwalk_datasource module
- datalogd.plugins.resources_rc module
- datalogd.plugins.sensoridentifierdatafilter module
- datalogd.plugins.sensorpaneldatafilter module
- datalogd.plugins.serial_datasource module
- datalogd.plugins.sinktimer_datafilter module
- datalogd.plugins.socket_datafilter module
- datalogd.plugins.thorlabspm100_datasource module
- datalogd.plugins.timestamp_datafilter module
- Submodules