'Handle a messages seen on the bus.'

def handle_message(self, message):

    from scsgate.messages import StateMessage, ScenarioTriggeredMessage
    self._logger.debug('Received    message    {}'.format(message))
    if ((not isinstance(message, StateMessage)) and (not isinstance(message, ScenarioTriggeredMessage))):
        msg = 'Ignored    message    {}    -    not    releavant    type'.format(message)
        self._logger.debug(msg)
        return
    if (message.entity in self._devices):
        new_device_activated = False
        with self._devices_to_register_lock:
            if (message.entity == self._device_being_registered):
                self._device_being_registered = None
                new_device_activated = True
        if new_device_activated:
            self._activate_next_device()
        try:
            self._devices[message.entity].process_event(message)
        except Exception as exception:
            msg = 'Exception    while    processing    event:    {}'.format(exception)
            self._logger.error(msg)
    else:
        self._logger.info('Ignoring    state    message    for    device    {}    because    unknonw'.format(message.entity))
