Ejemplo n.º 1
0
        def message_received(granule, h):

            stream_id = granule.stream_resource_id

            data_stream_id = granule.data_stream_id
            data_stream = granule.identifiables[data_stream_id]

            tstamp = get_datetime(data_stream.timestamp.value)

            records = granule.identifiables['record_count'].value

            log.info(
                'Received a message from stream %s with time stamp %s and %d records'
                % (stream_id, tstamp, records))

            if stream_id not in stream_defs:
                stream_defs[stream_id] = pubsub_cli.find_stream_definition(
                    stream_id, id_only=False).container
            stream_def = stream_defs.get(stream_id)

            sp = PointSupplementStreamParser(stream_definition=stream_def,
                                             stream_granule=granule)

            last_data = {}
            for field in sp.list_field_names():
                last_data[field] = sp.get_values(field)[-1]

            log.info('Last values in the message: %s' % str(last_data))
Ejemplo n.º 2
0
        def message_received(granule, h):

            stream_id = granule.stream_resource_id

            data_stream_id = granule.data_stream_id
            data_stream = granule.identifiables[data_stream_id]

            tstamp = get_datetime(data_stream.timestamp.value)

            records = granule.identifiables['record_count'].value
            

            log.info('Received a message from stream %s with time stamp %s and %d records' % (stream_id, tstamp, records))


            if stream_id not in stream_defs:
                stream_defs[stream_id] = pubsub_cli.find_stream_definition(stream_id, id_only=False).container
            stream_def = stream_defs.get(stream_id)

            sp = PointSupplementStreamParser(stream_definition=stream_def, stream_granule=granule)

            last_data = {}
            for field in sp.list_field_names():
                last_data[field] = sp.get_values(field)[-1]

            log.info('Last values in the message: %s' % str(last_data))
Ejemplo n.º 3
0
    def from_security_token(cls, token_obj):
        """ Factory method from a SecurityToken object """
        if not token_obj or not isinstance(token_obj, SecurityToken) \
                        or not token_obj.token_type in (TokenTypeEnum.OAUTH_ACCESS, TokenTypeEnum.OAUTH_REFRESH):
            raise BadRequest("Bad token object")

        oauth_token = OAuthTokenObj()
        oauth_token.access_token = token_obj.attributes.get("access_token", "")
        oauth_token.refresh_token = token_obj.attributes.get("refresh_token", "")
        oauth_token.token_type = "Bearer"
        oauth_token._scopes = token_obj.attributes.get("scopes", "")
        oauth_token.client_id = token_obj.attributes.get("client_id", "")
        oauth_token.expires = get_datetime(token_obj.expires, local_time=False)
        oauth_token.user = {"actor_id": token_obj.actor_id}
        oauth_token._token_obj = token_obj
        return oauth_token
Ejemplo n.º 4
0
    def from_security_token(cls, token_obj):
        """ Factory method from a SecurityToken object """
        if not token_obj or not isinstance(token_obj, SecurityToken) \
                        or not token_obj.token_type in (TokenTypeEnum.OAUTH_ACCESS, TokenTypeEnum.OAUTH_REFRESH):
            raise BadRequest("Bad token object")

        oauth_token = OAuthTokenObj()
        oauth_token.access_token = token_obj.attributes.get("access_token", "")
        oauth_token.refresh_token = token_obj.attributes.get(
            "refresh_token", "")
        oauth_token.token_type = "Bearer"
        oauth_token._scopes = token_obj.attributes.get("scopes", "")
        oauth_token.client_id = token_obj.attributes.get("client_id", "")
        oauth_token.expires = get_datetime(token_obj.expires, local_time=False)
        oauth_token.user = {"actor_id": token_obj.actor_id}
        oauth_token._token_obj = token_obj
        return oauth_token