def get_tag_aggregate(user_id, tag_id):
    """Retrieve all aggregates for a specific tag and user"""

    device_type = request.args.get('device_type', None)
    metrics = request.args.getlist('metrics', None)

    if device_type is None and len(metrics) == 0:
        device_types = get_supported_devices()
        for device_type in device_types:
            metrics.extend(get_metrics_names(device_type))
    elif len(metrics) == 0 and device_type is not None:
        metrics = get_metrics_names(device_type)
    elif len(metrics) > 0 and device_type is None:
        return "parameter 'device_type' is required to filter on `metrics`", 500

    #aggregates = _generate_mock_tag_aggregates(user_id, tag_id, device_type, metrics)
    aggregates = dao.get_aggregates(user_id, tag_id, device_type, metrics)

    return json.dumps(aggregates), 200
Beispiel #2
0
def get_tag_aggregate(user_id, tag_id):
    """Retrieve all aggregates for a specific tag and user"""

    device_type = request.args.get('device_type', None)
    metrics = request.args.getlist('metrics', None)

    if device_type is None and len(metrics) == 0:
        device_types = get_supported_devices()
        for device_type in device_types:
            metrics.extend(get_metrics_names(device_type))
    elif len(metrics) == 0 and device_type is not None:
        metrics = get_metrics_names(device_type)
    elif len(metrics) > 0 and device_type is None:
        return "parameter 'device_type' is required to filter on `metrics`", 500

    if mock_data_enabled:
        aggregates = _generate_mock_tag_aggregates(user_id, tag_id, device_type, metrics)
    else:
        aggregates = dao.get_aggregates(user_id, tag_id, device_type, metrics)

    return json.dumps(aggregates), 200
import argparse

from cloudbrain.publishers.PikaPublisher import PikaPublisher
from cloudbrain.publishers.PipePublisher import PipePublisher
from cloudbrain.utils.metadata_info import get_metrics_names, get_supported_devices
from cloudbrain.settings import RABBITMQ_ADDRESS, MOCK_DEVICE_ID

_SUPPORTED_DEVICES = get_supported_devices()



def validate_opts(opts):
    """
    validate that we've got the right options

    @param opts: (list) options to validate
    @retun opts_valid: (bool) 1 if opts are valid. 0 otherwise.
    """
    opts_valid = True
    if (opts.device_name == "openbci") and (opts.device_port is None):
        opts_valid = False
    return opts_valid



def get_args_parser():
    parser = argparse.ArgumentParser()

    parser.add_argument('-i', '--device_id', required=True,
                        help="A unique ID to identify the device you are sending data from. "
                             "For example: 'octopicorn2015'")
import argparse

from cloudbrain.publishers.PikaPublisher import PikaPublisher
from cloudbrain.publishers.PipePublisher import PipePublisher
from cloudbrain.utils.metadata_info import get_metrics_names, get_supported_devices
from cloudbrain.settings import RABBITMQ_ADDRESS, MOCK_DEVICE_ID

_SUPPORTED_DEVICES = get_supported_devices()


def validate_opts(opts):
    """
    validate that we've got the right options

    @param opts: (list) options to validate
    @retun opts_valid: (bool) 1 if opts are valid. 0 otherwise.
    """
    opts_valid = True
    if (opts.device_name == "openbci") and (opts.device_port is None):
        opts_valid = False
    return opts_valid


def get_args_parser():
    parser = argparse.ArgumentParser()

    parser.add_argument(
        '-i',
        '--device_id',
        required=True,
        help="A unique ID to identify the device you are sending data from. "
Beispiel #5
0
def get_device_names():
    """ Returns the device names from the metadata file  """
    return json.dumps(get_supported_devices())
Beispiel #6
0
def get_device_names():
    """ Returns the device names from the metadata file  """
    return json.dumps(get_supported_devices())