def test_display_map(client, first_sensor): assert first_sensor is not None display_map = DataPoint.display_map(client) assert display_map is not None readings = islice(first_sensor.timeseries(), 5) for reading in readings: values = [f(reading) for f in display_map.values()] assert values is not None
def _live(client, id, **kwargs): """Get live timeseries readings""" output_format = kwargs.get('format', client.format) if output_format == "tabular": raise ValueError("Tabular format is not supported for live " + "readings. Try --format csv " + "as the first argument") resource = _fetch_resource(client, id, **kwargs) timeseries = resource.timeseries(**kwargs) mapping = DataPoint.display_map(client) with cls.display_writer(client, mapping, **kwargs) as writer: with closing(timeseries.live()) as live: for data_point in live: writer.write_resources([data_point], mapping)
def _live(client, id=None, mac=False, **kwargs): """Get live timeseries readings.""" output_format = kwargs.get('format', client.format) if output_format == "tabular": raise ValueError("Tabular format is not supported for live " + "readings. Try --format csv " + "as the first argument") resource = _fetch_resource(client, id, mac=mac) timeseries = resource.timeseries(**kwargs) mapping = DataPoint.display_map(client) with cls.display_writer(client, mapping, **kwargs) as writer: with closing(timeseries.live()) as live: for data_point in live: writer.write_resources([data_point], mapping)