Esempio n. 1
0
def list_resource(session=None, **filters):
    """
    :param session:
    :param filters:
    :return: list blocks
    """
    return utils.list_db_objects(session, Resource, **filters)
Esempio n. 2
0
def get_fan_by_time(session, start_time, end_time):
    return utils.list_db_objects(session,
                                 Fan,
                                 created_at={
                                     'ge': str(start_time),
                                     'le': str(end_time)
                                 })
Esempio n. 3
0
def list_resource(session=None, **filters):
    """
    :param session:
    :param filters:
    :return: list blocks
    """
    return utils.list_db_objects(session, Resource, **filters)
Esempio n. 4
0
def _get_fan(session, gateway_id, uuid, order_by=[], limit=None, **kwargs):
    if isinstance(uuid, basestring):
        ids = {'eq': uuid}
    elif isinstance(uuid, list):
        ids = {'in': uuid}
    else:
        raise exception.InvalidParameter('parameter uuid format are not supported.')
    return \
        utils.list_db_objects(session, Fan, order_by=order_by, limit=limit, gateway_id=gateway_id, uuid=ids, **kwargs)
Esempio n. 5
0
def _get_history(session, gateway_id, uuid, order_by=[], limit=None, **kwargs):
    if isinstance(uuid, basestring):
        ids = {'eq': uuid}
    elif isinstance(uuid, list):
        ids = {'in': uuid}
    else:
        raise exception.InvalidParameter('parameter uuid format are not supported.')
    return \
        utils.list_db_objects(session, SmsHistroy, order_by=order_by, limit=limit, gateway_id=gateway_id, uuid=ids, **kwargs)
Esempio n. 6
0
def _get_fan(session, resource_id, order_by=[], limit=None, **kwargs):
    if isinstance(resource_id, int):
        resource_ids = {'eq': resource_id}
    elif isinstance(resource_id, list):
        resource_ids = {'in': resource_id}
    else:
        raise exception.InvalidParameter('parameter resource id format are not supported.')
    return \
        utils.list_db_objects(session, Fan, order_by=order_by, limit=limit, resource_id=resource_ids, **kwargs)
Esempio n. 7
0
def _get_buzzer(session, gateway_id, uuid, order_by=[], limit=None, **kwargs):
    if isinstance(uuid, basestring):
        ids = {"eq": uuid}
    elif isinstance(uuid, list):
        ids = {"in": uuid}
    else:
        raise exception.InvalidParameter("parameter uuid format are not supported.")
    return utils.list_db_objects(
        session, Buzzer, order_by=order_by, limit=limit, gateway_id=gateway_id, uuid=ids, **kwargs
    )
Esempio n. 8
0
def get_weather_by_date(session, start_time, end_time, **kwargs):
    date_range = {'ge': str(start_time), 'le': str(end_time)}
    return utils.list_db_objects(session, ActualWeather, publish_date=date_range, **kwargs)
Esempio n. 9
0
def get_power_by_date(session, start_time, end_time, **kwargs):
    date_range = {'ge': str(start_time), 'le': str(end_time)}
    return utils.list_db_objects(session, PredictedPower, publish_date=date_range, **kwargs) 
Esempio n. 10
0
def get_power_by_date(session, start_time, end_time, **kwargs):
    date_range = {'ge': str(start_time), 'le': str(end_time)}
    return utils.list_db_objects(session,
                                 ActualPower,
                                 collect_date=date_range,
                                 **kwargs)
Esempio n. 11
0
def get_power_by_date(session, start_time, end_time, **kwargs):
    date_range = {'ge': str(start_time), 'le': str(end_time)}
    return utils.list_db_objects(session,
                                 PredictedPower,
                                 publish_date=date_range,
                                 **kwargs)
Esempio n. 12
0
def get_power(session, **kwargs):
    return utils.list_db_objects(session, PredictedPower, **kwargs)
Esempio n. 13
0
def get_all_types(session):
    return utils.list_db_objects(session, SensorType)
Esempio n. 14
0
def get_weather_by_date(session, start_time, end_time, **kwargs):
    date_range={'ge': str(start_time), 'le': str(end_time)}
    return utils.list_db_objects(session, ActualWeather, publish_date=date_range, **kwargs) 
Esempio n. 15
0
def list_gateways(session, **kwargs):
    return utils.list_db_objects(session, Gateway, **kwargs)
Esempio n. 16
0
def get_all_groups(session, gateway_id):
    return utils.list_db_objects(session, SensorGroup, gateway_id=gateway_id)
Esempio n. 17
0
def get_power(session, **kwargs):
    return utils.list_db_objects(session, PredictedPower, **kwargs)
Esempio n. 18
0
def get_all_user_names(session):
    users = utils.list_db_objects(session, User, exception_when_missing=False, status=True)
    u_list = [u.username for u in users if u.username]
    return set(u_list)
Esempio n. 19
0
def list_gateways(session, **kwargs):
    return utils.list_db_objects(session, Gateway, **kwargs)
Esempio n. 20
0
def get_user_phone_by_gateway(session, gateway_id, exception_when_missing=True):
    users = utils.list_db_objects(session, User, exception_when_missing=exception_when_missing, gateway_id=gateway_id)
    return [u.phone for u in users]
Esempio n. 21
0
def get_fan_by_time(session, start_time, end_time):
    return utils.list_db_objects(session, Fan, created_at={'ge': str(start_time), 'le': str(end_time)})
Esempio n. 22
0
def get_power_by_date(session, start_time, end_time, **kwargs):
    date_range={'ge': str(start_time), 'le': str(end_time)}
    return utils.list_db_objects(session, ActualPower, collect_date=date_range, **kwargs)