コード例 #1
0
ファイル: user.py プロジェクト: simonchapman1986/ripe
def missing_user_id(event_name, description):
    """
    missing_user_id

    in the event that a user is yet to exist, we must flag this error accordingly as this is not a create user event.
    """
    register_flag(
        type=MISSING_DATA,
        description=description,
        event=event_name
    )
コード例 #2
0
def item(item_id, event_name, cls):
    """
    item

    to be used to check if an item exists, if it doesnt, we create a flag within the RIPE system
    """
    try:
        cls.objects.get(item_id=item_id)
    except cls.DoesNotExist:
        register_flag(type=DOES_NOT_EXIST,
                      description=DESCRIPTION.format(item_id),
                      event=event_name)
コード例 #3
0
def right(right_id, event_name, cls):
    """
    right

    usage rights are supposed to be ingested by the locker events. If a usage right is yet to exist we
    flag this up.
    """
    try:
        cls.objects.get(right_id=right_id)
    except cls.DoesNotExist:
        register_flag(type=DOES_NOT_EXIST,
                      description=DESCRIPTION.format(right_id),
                      event=event_name)
コード例 #4
0
ファイル: subscription.py プロジェクト: simonchapman1986/ripe
def get_rule(status=0, current_state=RNS, window_ongoing=False):
    """
    >>> get_rule(status=0, current_state=RNS, window_ongoing=True)
    'registered_never_subscribed'
    >>> get_rule(status=1, current_state=RNS, window_ongoing=True)
    'subscriber_ongoing'
    >>> get_rule(status=1, current_state=RNS, window_ongoing=False)
    'subscriber_fixed'
    """
    # default to current state
    next_state = current_state
    _ov = False
    err = False

    # get string of our status
    _status = subscription_status_lookup[int(status)]

    ## if we are an active lets generate, else...
    #sub_status = "{}-{}".format(
    #    subscription_status_lookup[status],
    #    ONGOING if window_ongoing else FIXED) if _status == ACTIVE else _status
    if window_ongoing:
        user_sub = user_sub_ongoing
    else:
        user_sub = user_sub_not_ongoing


    # look through the possibilities and break out if we match
    for current, next_state, event in user_sub:
        if event == _status:
            if current == current_state:
                _ov = True
                break

    if not _ov:
        # error state.. we will use current to continue
        # lets flag the error
        register_flag(
            type=BUSINESS_RULE_NOT_MET,
            description='recieved status({}) with current_state({}) - failed to match business rule'.format(
                _status,
                current_state
            ),
            event='subscription'
        )
        # flag an error state
        err = True


    return next_state, err
コード例 #5
0
ファイル: item.py プロジェクト: simonchapman1986/ripe
def item(item_id, event_name, cls):
    """
    item

    to be used to check if an item exists, if it doesnt, we create a flag within the RIPE system
    """
    try:
        cls.objects.get(item_id=item_id)
    except cls.DoesNotExist:
        register_flag(
            type=DOES_NOT_EXIST,
            description=DESCRIPTION.format(item_id),
            event=event_name
        )
コード例 #6
0
ファイル: right.py プロジェクト: simonchapman1986/ripe
def right(right_id, event_name, cls):
    """
    right

    usage rights are supposed to be ingested by the locker events. If a usage right is yet to exist we
    flag this up.
    """
    try:
        cls.objects.get(right_id=right_id)
    except cls.DoesNotExist:
        register_flag(
            type=DOES_NOT_EXIST,
            description=DESCRIPTION.format(right_id),
            event=event_name
        )
コード例 #7
0
ファイル: client.py プロジェクト: simonchapman1986/ripe
def client(client_id, event_name):
    """
    client

    used to assert whether the client does indeed exist in our ingested clients table, if not this is a potential
    issue and it must be flagged
    """
    try:
        Clients.objects.get(id=client_id)
    except Clients.DoesNotExist:
        register_flag(
            type=DOES_NOT_EXIST,
            description=DESCRIPTION.format(client_id),
            event=event_name
        )
コード例 #8
0
ファイル: fact_tools.py プロジェクト: simonchapman1986/ripe
def save_platform(data, event='unknown'):
    res = DimensionPlatform.insert(
        os=data.get('platform_os', None),
        name=data.get('platform_name', None),
        version=data.get('platform_version', None)
    ) if any(
        [p in data for p in ['platform_os', 'platform_name', 'platform_version']]
    ) else None

    if not res:
        register_flag(
            type=MISSING_DATA,
            event=event,
            description='No platform information provided in event.'
        )
    return res
コード例 #9
0
def get_rule(status=0, current_state=RNS, window_ongoing=False):
    """
    >>> get_rule(status=0, current_state=RNS, window_ongoing=True)
    'registered_never_subscribed'
    >>> get_rule(status=1, current_state=RNS, window_ongoing=True)
    'subscriber_ongoing'
    >>> get_rule(status=1, current_state=RNS, window_ongoing=False)
    'subscriber_fixed'
    """
    # default to current state
    next_state = current_state
    _ov = False
    err = False

    # get string of our status
    _status = subscription_status_lookup[int(status)]

    ## if we are an active lets generate, else...
    #sub_status = "{}-{}".format(
    #    subscription_status_lookup[status],
    #    ONGOING if window_ongoing else FIXED) if _status == ACTIVE else _status
    if window_ongoing:
        user_sub = user_sub_ongoing
    else:
        user_sub = user_sub_not_ongoing

    # look through the possibilities and break out if we match
    for current, next_state, event in user_sub:
        if event == _status:
            if current == current_state:
                _ov = True
                break

    if not _ov:
        # error state.. we will use current to continue
        # lets flag the error
        register_flag(
            type=BUSINESS_RULE_NOT_MET,
            description=
            'recieved status({}) with current_state({}) - failed to match business rule'
            .format(_status, current_state),
            event='subscription')
        # flag an error state
        err = True

    return next_state, err
コード例 #10
0
ファイル: fact_tools.py プロジェクト: simonchapman1986/ripe
def save_user(data, territory, client, event='unknown'):
    res = DimensionUser.insert(
        external_user_id=data.get('external_user_id', None),
        internal_user_id=data.get('internal_user_id', None),
        territory=territory,
        client=client
    ) if any([
        data.get('external_user_id', None),
        data.get('internal_user_id', False),
        territory,
        client
    ]) else None

    if not res:
        register_flag(
            type=MISSING_DATA,
            event=event,
            description='No user information provided in event.'
        )
    return res