@Override(ConcurrentExperiment.ConcurrentExperiment)
    def do_send_command_to_device(self, lab_session_id, command):
        
        # get_status => status
        if command.startswith('get_status'):
            return self._status_manager.get_status_str()

        # turn:1:on => status (or "error:Message"
        if command.startswith('turn:'):
            remainder = command[len('turn:'):]
            regex = re.compile('([^:]*):(on|off)')
            obj = regex.match(remainder)
            if obj is None: 
                return "error:Malformed turn: command"
            number, new_state = obj.groups()
            
            message = self._status_manager.turn_light(number, new_state)

            if message is not None:
                return "error:%s" % message
            elif self._verbose:
                print "Turning light %s %s succeeded. New status: %s" % (number, new_state, self._status_manager.get_status_str())

            return self._status_manager.get_status_str()
    
        # get_historic:2012/12/31 => dictionary with the data
        if command.startswith('get_historic:'):
            remainder = command[len('get_historic:'):]
            regex = re.compile('(\d*)/(\d*)/(\d*)')
            obj = regex.match(remainder)
            if obj is None:
                return "error:Malformed get_historic command"
            year, month, day = obj.groups()
            return json.dumps(self._status_manager.retrieve_historic(year, month, day))

        return 'Command not found'
dataset/ETHPy150Open weblabdeusto/weblabdeusto/server/src/experiments/incubator.py/IncubatorExperiment.do_send_command_to_device/original