def execute_task(self, task, timeout, **kwargs):
        log_prefix = "%s - " % (task.id,)
        monitor = Monitor.registry[task.context['monitor']['name']]
        command = monitor.command.command_string
        current_attempt = int(task.attempt) + 1
        logger.debug(log_prefix + "attempt %d, executing: %s", current_attempt,
                     command)
        result = Result({'id': task.id,
                         'timestamp': task.created,
                         'task_context': task.context})
        try:
            output = monitor.execute(task.context, timeout,
                                     self._private_context)
            result.output = output
            result.state = types.STATE_OK
        except commands.CommandException as e:
            if isinstance(e, commands.CommandFailure):
                result.state = e.return_code
                result.output = e.output
            if isinstance(e, commands.CommandTimeout):
                result.state = types.STATE_UNKNOWN
                result.output = (TIMEOUT_OUTPUT % timeout)
        except Exception as e:
            result.state = types.STATE_UNKNOWN
            result.output = str(e)
        result.state_type = types.STATE_TYPE_HARD
        result.validate()
        return result
dataset/ETHPy150Open cloudtools/nymms/nymms/probe/Probe.py/Probe.execute_task/original