

def _process_block(self, block, exists):
    error = None
    try:
        self._do_checks(block, exists)
        event_type = 'compute.instance.exists.verified'
    except UsageException as e:
        error = e
        event_type = 'compute.instance.exists.failed'
        logger.warn(('Stream %s UsageException: (%s) %s' % (self.stream_id, e.code, e)))
        (apb, ape) = self._get_audit_period(exists)
        logger.warn(('Stream %s deleted_at: %s, launched_at: %s, state: %s, APB: %s, APE: %s, #events: %s' % (self.stream_id, exists.get('deleted_at'), exists.get('launched_at'), exists.get('state'), apb, ape, len(block))))
    if (len(block) > 1):
        logger.warn(('%s - events (stream: %s)' % (event_type, self.stream_id)))
        for event in block:
            logger.warn(('^Event: %s - %s' % (event['timestamp'], event['event_type'])))
    events = []
    if self.warnings:
        instance_id = exists.get('instance_id', 'n/a')
        warning_event = {
            'event_type': 'compute.instance.exists.warnings',
            'publisher_id': 'stv3',
            'message_id': str(uuid.uuid4()),
            'timestamp': exists.get('timestamp', datetime.datetime.utcnow()),
            'stream_id': int(self.stream_id),
            'instance_id': instance_id,
            'warnings': ', '.join(self.warnings),
        }
        events.append(warning_event)
    new_event = self._base_notification(exists)
    new_event['message_id'] = self._generate_new_id(new_event['original_message_id'], event_type)
    new_event.update({
        'event_type': event_type,
        'publisher_id': 'stv3',
        'timestamp': exists.get('timestamp', datetime.datetime.utcnow()),
        'stream_id': int(self.stream_id),
        'error': str(error),
        'error_code': (error and error.code),
    })
    events.append(new_event)
    return events

dataset/ETHPy150Open openstack/stacktach-winchester/winchester/pipeline_handler.py UsageHandler._process_block/original