def _execute(self, cprefix, command):
        if not command:
            raise iex.BadRequest("execute argument 'command' not present")
        if not command.command:
            raise iex.BadRequest("command not set")

        cmd_res = IonObject("AgentCommandResult", command_id=command.command_id, command=command.command)
        cmd_func = getattr(self, cprefix + str(command.command), None)
        if cmd_func:
            cmd_res.ts_execute = get_ion_ts()
            try:
                res = cmd_func(*command.args, **command.kwargs)
                cmd_res.status = 0
                cmd_res.result = res
            except iex.IonException as ex:
                # TODO: Distinguish application vs. uncaught exception
                cmd_res.status = getattr(ex, 'status_code', -1)
                cmd_res.result = str(ex)
                log.warn("Agent command %s failed with trace=%s" % (command.command, traceback.format_exc()))
        else:
            log.info("Agent command not supported: %s" % (command.command))
            ex = iex.NotFound(command.command % "Command not supported: %s")
            cmd_res.status = iex.NotFound.status_code
            cmd_res.result = str(ex)

        sub_type = "%s.%s" % (command.command, cmd_res.status)
        event_data = self._post_execute_event_hook(event_type=self.COMMAND_EVENT_TYPE,
            origin=self.resource_id, origin_type=self.ORIGIN_TYPE,
            sub_type=sub_type, command=str(command.command),
            result=str(cmd_res.result))
        post_event = self._event_publisher.publish_event(**event_data)

        return cmd_res
dataset/ETHPy150Open ooici/pyon/pyon/agent/simple_agent.py/SimpleResourceAgent._execute/swapped operands of `%`