def turn_light(self, number, new_status):
        """
        Turn a particular light (number = '1') or all the lights (number = 'all') on or off.
        If a string is returned, an error has ocurred and the error message may be logged and
        even returned. If None is returned, everything was fine.
        """
        if new_status not in ('on','off'):
            return "Wrong status!"
        
        self.update_temperature()

        # Lock the operation, so two threads can not change the status
        with self._operations_lock:
            
            # Lock the status, but make a fast operation
            with self._status_lock:
                if number == 'all':
                    for light in self._all_lights:
                        self._status[light] = new_status
                elif number in self._all_lights:
                    self._status[number] = new_status
                else:
                    return 'Wrong number! (use "all" or 1-%s' % self._lights
            
            if number == 'all':
                return self._perform_post_request('/EGGS%s' % new_status.upper())
            else:
                return self._perform_post_request('/EGG/%s/value/%s' % (number, new_status))
dataset/ETHPy150Open weblabdeusto/weblabdeusto/server/src/experiments/incubator.py/StatusManager.turn_light/original