Get result from pollers/reactionners (actives ones)

        :param action: check / action / event handler to handle
        :type action:
        :return: None
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))
689145
def getTransitionActor(obj, action_id):
    
    review_history = getReviewHistory(obj)
    for event in review_history:
        if event.get('action') == action_id:
            return event.get('actor')
    return None
959695
def get_action(self, parent, undo_stack: QUndoStack, sel_range, groups,
                   view: int) -> QUndoCommand:
        
        raise NotImplementedError("Abstract Method.")
581050
def get_actions(self, request):
        
        # If self.actions is explicitly set to None that means that we don't
        # want *any* actions enabled on this page.
        if self.actions is None:
            return OrderedDict()

        actions = []

        # Gather actions from the admin site first
        for (name, func) in self.admin_site.actions:
            description = getattr(
                func, 'short_description', name.replace('_', ' '))
            actions.append((func, name, description))

        # Then gather them from the model admin and all parent classes,
        # starting with self and working back up.
        for klass in self.__class__.mro()[::-1]:
            class_actions = getattr(klass, 'actions', [])
            # Avoid trying to iterate over None
            if not class_actions:
                continue
            actions.extend(self.get_action(action) for action in class_actions)

        # get_action might have returned None, so filter any of those out.
        actions = filter(None, actions)

        # Convert the actions into an OrderedDict keyed by name.
        actions = OrderedDict(
            (name, (func, name, desc))
            for func, name, desc in actions
        )

        if 'delete_selected' in actions:
            del actions['delete_selected']
        return actions
135549
async def trigger(self, action, args):
        
        handler_name = f"on_{action}"
        handler = getattr(self, handler_name, None)
        if not handler:
            return None
        await handler(*args)
1327314
public static ProcessorActionHandler getHandler(ProcessorAction action) {
        ProcessorActionHandler ret = null;
        Class<? extends ProcessorActionHandler> cls = handlers.get(action.getClass());
        if (cls != null) {
            try {
                Constructor<? extends ProcessorActionHandler> con = cls.getConstructor(ProcessorAction.class);
                ret = con.newInstance(action);
            } catch (Exception e) {
                log.log(Level.SEVERE, "Failed to instantiate handler for action '" + action + "'", e);
            }
        }
        return ret;
    }
577039
def get_actions(self, request, view):
        
        metadata = OrderedDict()
        actions = self.get_resource_actions(view)

        resource = view.get_object()
        for action_name, action in actions.items():
            if action_name == 'update':
                view.request = clone_request(request, 'PUT')
            else:
                view.action = action_name

            data = ActionSerializer(action, action_name, request, view, resource)
            metadata[action_name] = data.serialize()
            if not metadata[action_name]['enabled']:
                continue
            fields = self.get_action_fields(view, action_name, resource)
            if not fields:
                metadata[action_name]['type'] = 'button'
            else:
                metadata[action_name]['type'] = 'form'
                metadata[action_name]['fields'] = fields

            view.action = None
            view.request = request

        return metadata
654634
def _get_action(self, action_meta):
        '''
        
        '''
        conf = {
            'fun': list(action_meta.keys())[0],
            'arg': [],
            'kwargs': {},
        }
        if not len(conf['fun'].split('.')) - 1:
            conf['salt.int.intfunc'] = True

        action_meta = action_meta[conf['fun']]
        info = action_meta.get('info', 'Action for {}'.format(conf['fun']))
        for arg in action_meta.get('args') or []:
            if not isinstance(arg, dict):
                conf['arg'].append(arg)
            else:
                conf['kwargs'].update(arg)

        return info, action_meta.get('output'), conf
368376
def get_action_by_id(self, action_id):
        
        parsed_json, raw_json = self._call('getactionbyid', element_id=action_id)
        action = Action.object_from_api(parsed_json, raw_json)
        return action
872313
def do_get_new_actions(self):
        
        # Here are the differences between a poller and a reactionner:
        # Poller will only do checks,
        # Reactionner will do actions (notifications and event handlers)
        do_checks = self.__class__.do_checks
        do_actions = self.__class__.do_actions

        # We check and get the new actions to execute in each of our schedulers
        for scheduler_link_uuid in self.schedulers:
            scheduler_link = self.schedulers[scheduler_link_uuid]

            if not scheduler_link.active:
                logger.warning("My scheduler '%s' is not active currently", scheduler_link.name)
                continue

            logger.debug("get new actions, scheduler: %s", scheduler_link.name)

            # OK, go for it :)
            _t0 = time.time()
            actions = scheduler_link.get_actions({'do_checks': do_checks, 'do_actions': do_actions,
                                                  'poller_tags': self.poller_tags,
                                                  'reactionner_tags': self.reactionner_tags,
                                                  'worker_name': self.name,
                                                  'module_types': list(self.q_by_mod.keys())})
            if actions:
                logger.debug("Got %d actions from %s", len(actions), scheduler_link.name)
                # We 'tag' them with my_scheduler and put into queue for workers
                self.add_actions(actions, scheduler_link.instance_id)
                logger.debug("Got %d actions from %s in %s",
                             len(actions), scheduler_link.name, time.time() - _t0)
            statsmgr.gauge('actions.added.count.%s' % (scheduler_link.name), len(actions))
1077873
function(action, settings){
            var handler = this.performableActions[action];
            if(!handler){
                return false;
            }

            if(!handler.getTargetsForAction){
                return false;
            }

            settings = settings || {};
            if(!settings.skipCanPerformAction && !this.canPerformAction(action, settings)){
                return false;
            }

            return handler.getTargetsForAction.call(this, settings);
        }
634121
def action_getattr():
    

    def action_getattr(_value, context, **_params):
        value = getattr(context["action"], context["key"])
        return _attr(value)

    return action_getattr
471471
def _result_handler(self, response: Dict[str, Any]):
        
        res = response.get("MESSAGE")
        ID = res.get("ID")
        result = res.get("RESULT")
        fut = self.tasks.get(ID)
        fut.set_result(result)
        return True
384614
def get_action(self):
        
        action = self.request.get("workflow_action_id", None)
        action = self.request.get("workflow_action", action)
        if not action:
            return None

        # A condition in the form causes Plone to sometimes send two actions
        # This usually happens when the previous action was not managed properly
        # and the request was not able to complete, so the previous form value
        # is kept, together with the new one.
        if type(action) in (list, tuple):
            actions = list(set(action))
            if len(actions) > 0:
                logger.warn("Multiple actions in request: {}. Fallback to '{}'"
                            .format(repr(actions), actions[-1]))
            action = actions[-1]
        return action
650284
def manage_action_return(self, action):
        
        # Maybe our workers send us something else than an action
        # if so, just add this in other queues and return
        # todo: test a class instance
        if action.__class__.my_type not in ['check', 'notification', 'eventhandler']:
            self.add(action)
            return

        # Ok, it's a result. Get the concerned scheduler uuid
        scheduler_uuid = action.my_scheduler
        logger.debug("Got action return: %s / %s", scheduler_uuid, action.uuid)

        try:
            # Now that we know where to put the action result, we do not need any reference to
            # the scheduler nor the worker
            del action.my_scheduler
            del action.my_worker
        except AttributeError:  # pragma: no cover, simple protection
            logger.error("AttributeError Got action return: %s / %s", scheduler_uuid, action)

        # And we remove it from the actions queue of the scheduler too
        try:
            del self.schedulers[scheduler_uuid].actions[action.uuid]
        except KeyError as exp:
            logger.error("KeyError del scheduler action: %s / %s - %s",
                         scheduler_uuid, action.uuid, str(exp))

        # We tag it as "return wanted", and move it in the wait return queue
        try:
            self.schedulers[scheduler_uuid].wait_homerun[action.uuid] = action
        except KeyError:  # pragma: no cover, simple protection
            logger.error("KeyError Add home run action: %s / %s - %s",
                         scheduler_uuid, action.uuid, str(exp))
582985
def call_action(input)
      @action.respond_to?(:call) ? @action.call(input) : Rc.send(@action, input)
    rescue StandardError, SyntaxError
      message = $!.is_a?(NoMethodError) && !@action.respond_to?(:call) &&
        !Rc.respond_to?(@action) ? "Completion action '#{@action}' doesn't exist." :
        "Failed during completion action '#{name}' with '#{$!.message}'."
      raise FailedMissionError.new(self), message
    end
1054885
def view(self, action, **kwds):
        
        result = self._client.get("/action/%s/view.json" %
                                  self._extract_id(action),
                                  **kwds)["result"]
        return Action(self._client, result)