Process the actions we want to take

        Args:
            actions (`list`): List of actions we want to take

        Returns:
            `list` of notifications
167385
def process_actions(self, actions):
        
        notices = {}
        notification_contacts = {}
        for action in actions:
            resource = action['resource']
            action_status = ActionStatus.SUCCEED

            try:
                if action['action'] == AuditActions.REMOVE:
                    action_status = self.process_action(
                        resource,
                        AuditActions.REMOVE
                    )
                    if action_status == ActionStatus.SUCCEED:
                        db.session.delete(action['issue'].issue)

                elif action['action'] == AuditActions.STOP:
                    action_status = self.process_action(
                        resource,
                        AuditActions.STOP
                    )
                    if action_status == ActionStatus.SUCCEED:
                        action['issue'].update({
                            'missing_tags': action['missing_tags'],
                            'notes': action['notes'],
                            'last_alert': action['last_alert'],
                            'state': action['action']
                        })

                elif action['action'] == AuditActions.FIXED:
                    db.session.delete(action['issue'].issue)

                elif action['action'] == AuditActions.ALERT:
                    action['issue'].update({
                        'missing_tags': action['missing_tags'],
                        'notes': action['notes'],
                        'last_alert': action['last_alert'],
                        'state': action['action']
                    })

                db.session.commit()

                if action_status == ActionStatus.SUCCEED:
                    for owner in [
                        dict(t) for t in {tuple(d.items()) for d in (action['owners'] + self.permanent_emails)}
                    ]:
                        if owner['value'] not in notification_contacts:
                            contact = NotificationContact(type=owner['type'], value=owner['value'])
                            notification_contacts[owner['value']] = contact
                            notices[contact] = {
                                'fixed': [],
                                'not_fixed': []
                            }
                        else:
                            contact = notification_contacts[owner['value']]

                        if action['action'] == AuditActions.FIXED:
                            notices[contact]['fixed'].append(action)
                        else:
                            notices[contact]['not_fixed'].append(action)
            except Exception as ex:
                self.log.exception('Unexpected error while processing resource {}/{}/{}/{}'.format(
                    action['resource'].account.account_name,
                    action['resource'].id,
                    action['resource'],
                    ex
                ))

        return notices
482452
def execute(self, elem_list):
        
        if self.condition.is_true(elem_list):
            return self.action.act(elem_list)
        else:
            return elem_list
874351
async def check_permissions(self, action: str, **kwargs):
        
        for permission in await self.get_permissions(action=action, **kwargs):

            if not await ensure_async(permission.has_permission)(
                    scope=self.scope, consumer=self, action=action, **kwargs):
                raise PermissionDenied()
1359028
def actions(self):
        
        r = self.session.query(models.Action).all()
        return [x.type_name for x in r]
663697
def on_action_begin(self, action, logs={}):
        
        for callback in self.callbacks:
            if callable(getattr(callback, 'on_action_begin', None)):
                callback.on_action_begin(action, logs=logs)
498493
def actions(self, req_action):
    """"""
    if FLAGS.sc2_log_actions:
      for action in req_action.actions:
        sys.stderr.write(str(action))
        sys.stderr.flush()

    return self._client.send(action=req_action)
294188
def enable_actions(options = {})
      options = Aws::Util.deep_merge(options, alarm_names: [@name])
      resp = @client.enable_alarm_actions(options)
      resp.data
    end
517108
def manage_results(self, action):  # pylint: disable=too-many-branches,too-many-statements
        
        logger.debug('manage_results: %s ', action)
        if action.is_a == 'notification':
            try:
                _ = self.actions[action.uuid]
            except KeyError as exp:  # pragma: no cover, simple protection
                # Cannot find notification - drop it
                logger.warning('manage_results:: get unknown notification : %s ', str(exp))
                for uuid in self.actions:
                    logger.debug('manage_results:: known action: %s ', self.actions[uuid])
                return

            # We will only see child notifications here
            try:
                timeout = False
                execution_time = 0
                if action.status == ACT_STATUS_TIMEOUT:
                    # Unfortunately the remove_in_progress_notification
                    # sets the status to zombie, so we need to save it here.
                    timeout = True
                    execution_time = action.execution_time

                # Add protection for strange charset
                try:
                    action.output = action.output.decode('utf8', 'ignore')
                except UnicodeDecodeError:
                    pass
                except AttributeError:
                    # Python 3 will raise an exception
                    pass

                self.actions[action.uuid].get_return_from(action)
                item = self.find_item_by_id(self.actions[action.uuid].ref)
                item.remove_in_progress_notification(action)
                self.actions[action.uuid].status = ACT_STATUS_ZOMBIE
                item.last_notification = int(action.check_time)

                # And we ask the item to update its state
                self.get_and_register_status_brok(item)

                # If we' ve got a problem with the notification, raise a Warning log
                if timeout:
                    contact = self.find_item_by_id(self.actions[action.uuid].contact)
                    item = self.find_item_by_id(self.actions[action.uuid].ref)

                    self.nb_actions_results_timeout += 1

                    logger.warning("Contact %s %s notification command '%s ' "
                                   "timed out after %.2f seconds",
                                   contact.contact_name,
                                   item.my_type,
                                   self.actions[action.uuid].command,
                                   execution_time)
                else:
                    self.nb_actions_results += 1

                    if action.exit_status != 0:
                        logger.warning("The notification command '%s' raised an error "
                                       "(exit code=%d): '%s'",
                                       action.command, action.exit_status, action.output)

            except (ValueError, AttributeError) as exp:  # pragma: no cover, simple protection
                # bad object, drop it
                logger.warning('manage_results:: got bad notification : %s ', str(exp))

        elif action.is_a == 'check':
            try:
                check = self.checks[action.uuid]
            except KeyError as exp:  # pragma: no cover, simple protection
                # Cannot find check - drop it
                logger.warning('manage_results:: get unknown check: %s ', action)
                for uuid in self.checks:
                    logger.debug('manage_results:: known check: %s ', self.checks[uuid])
                return

            try:
                if action.status == ACT_STATUS_TIMEOUT:
                    ref = self.find_item_by_id(check.ref)
                    action.long_output = action.output
                    action.output = "(%s %s check timed out)" % (ref.my_type, ref.get_full_name())
                    action.exit_status = self.pushed_conf.timeout_exit_status

                    self.nb_checks_results_timeout += 1

                    logger.warning("Timeout raised for '%s' (check command for the %s '%s'), "
                                   "check status code: %d, execution time: %d seconds",
                                   action.command, ref.my_type, ref.get_full_name(),
                                   action.exit_status, int(action.execution_time))
                else:
                    self.nb_checks_results += 1
                    if action.passive_check:
                        self.nb_checks_results_passive += 1
                    else:
                        self.nb_checks_results_active += 1

                        check.get_return_from(action)
                check.status = ACT_STATUS_WAIT_CONSUME
                if check._is_orphan and os.getenv('ALIGNAK_LOG_CHECKS', None):
                    logger.info("--ALC-- got a result for an orphan check: %s", check)

            except (ValueError, AttributeError) as exp:  # pragma: no cover, simple protection
                # bad object, drop it
                logger.warning('manage_results:: got bad check: %s ', str(exp))

        elif action.is_a == 'eventhandler':
            try:
                old_action = self.actions[action.uuid]
                old_action.status = ACT_STATUS_ZOMBIE
            except KeyError as exp:  # pragma: no cover, simple protection
                # cannot find old action
                # bad object, drop it
                logger.warning('manage_results:: get bad check: %s ', str(exp))
                return

            try:
                if action.status == ACT_STATUS_TIMEOUT:
                    _type = 'event handler'
                    if action.is_snapshot:
                        _type = 'snapshot'
                    ref = self.find_item_by_id(self.checks[action.uuid].ref)
                    logger.info("%s %s command '%s' timed out after %d seconds",
                                ref.__class__.my_type.capitalize(),  # pylint: disable=E1101
                                _type, self.actions[action.uuid].command,
                                int(action.execution_time))

                    self.nb_actions_results_timeout += 1
                else:
                    self.nb_actions_results += 1

                # If it's a snapshot we should get the output and export it
                if action.is_snapshot:
                    old_action.get_return_from(action)
                    s_item = self.find_item_by_id(old_action.ref)
                    self.add(s_item.get_snapshot_brok(old_action.output, old_action.exit_status))
            except (ValueError, AttributeError) as exp:  # pragma: no cover, simple protection
                # bad object, drop it
                logger.warning('manage_results:: got bad event handler: %s ', str(exp))

        else:  # pragma: no cover, simple protection, should not happen!
            logger.error("The received result type in unknown! %s", str(action.is_a))
1358493
def actionnames(self):
        
        actions = []
        for service_name in sorted(self.services.keys()):
            action_names = self.services[service_name].actions.keys()
            for action_name in sorted(action_names):
                actions.append((service_name, action_name))
        return actions
1044361
def run_actions
        catch_exceptions do
          @success = if block_given?
            result = yield
            actions.each {|action| results[action] = result}
            !!result
          else
            actions.compact.each {|action| !skip_actions && results[action] = object.send(action)}
            results.values.all?
          end
        end
      end
616323
def _add_action(self, notification, action, label, callback, *args):
        
        on_action_click = run_bg(lambda *_: callback(*args))
        try:
            # this is the correct signature for Notify-0.7, the last argument
            # being 'user_data':
            notification.add_action(action, label, on_action_click, None)
        except TypeError:
            # this is the signature for some older version, I don't know what
            # the last argument is for.
            notification.add_action(action, label, on_action_click, None, None)
        # gi.Notify does not store hard references to the notification
        # objects. When a signal is received and the notification does not
        # exist anymore, no handler will be called. Therefore, we need to
        # prevent these notifications from being destroyed by storing
        # references:
        notification.connect('closed', self._notifications.remove)
        self._notifications.append(notification)
390354
async def listen_notifications(self, fallback_callback=None):
        
        tasks = []

        async def handle_notification(notification):
            if type(notification) not in self.callbacks:
                if not fallback_callback:
                    _LOGGER.debug("No callbacks for %s", notification)
                    # _LOGGER.debug("Existing callbacks for: %s" % self.callbacks)
                else:
                    await fallback_callback(notification)
                return
            for cb in self.callbacks[type(notification)]:
                await cb(notification)

        for serv in self.services.values():
            tasks.append(
                asyncio.ensure_future(
                    serv.listen_all_notifications(handle_notification)
                )
            )

        try:
            print(await asyncio.gather(*tasks))
        except Exception as ex:
            # TODO: do a slightly restricted exception handling?
            # Notify about disconnect
            await handle_notification(ConnectChange(connected=False, exception=ex))
            return
1338262
def push_actions_to_passive_satellites(self):
        
        # We loop for our passive pollers or reactionners
        for satellites in [self.my_daemon.pollers, self.my_daemon.reactionners]:
            s_type = 'poller'
            if satellites is self.my_daemon.reactionners:
                s_type = 'reactionner'

            for link in [s for s in list(satellites.values()) if s.passive]:
                logger.debug("Try to send actions to the %s '%s'", s_type, link.name)

                # Get actions to execute
                lst = []
                if s_type == 'poller':
                    lst = self.get_to_run_checks(do_checks=True, do_actions=False,
                                                 poller_tags=link.poller_tags,
                                                 worker_name=link.name)
                elif s_type == 'reactionner':
                    lst = self.get_to_run_checks(do_checks=False, do_actions=True,
                                                 reactionner_tags=link.reactionner_tags,
                                                 worker_name=link.name)
                if not lst:
                    logger.debug("Nothing to do...")
                    continue

                logger.debug("Sending %d actions to the %s '%s'", len(lst), s_type, link.name)
                link.push_actions(lst, self.instance_id)
1280545
def notifications(self):
        
        if self._notifications is None:
            self._notifications = NotificationList(self._version, service_sid=self._solution['sid'], )
        return self._notifications
336138
def model_actions(self):
        
        observations = self.get('rollout:observations')
        model_action = self.model.action(observations)
        return model_action
804344
def dispatch(self, action: Action) -> Any:
        
        LOG.debug("Dispatching action %s, %s", action["type"], action["callback_id"])

        if action["type"] == "interactive_message":
            yield from self._dispatch_interactive_message(action)
        elif action["type"] in ("dialog_submission", "message_action"):
            yield from self._dispatch_action(action)
        else:
            raise UnknownActionType(action)
278144
def process_action(self, request, queryset):
        
        count = 0
        for obj in queryset:
            count += 1
            obj.unpublish()
            object_url = self.get_object_url(obj)
            self.log_action(obj, CMSLog.UNPUBLISH, url=object_url)
        url = self.get_done_url()
        msg = self.write_message(message="%s objects unpublished." % count)
        return self.render(request, redirect_url=url,
                                message=msg,
                                collect_render_data=False)