def publish_and_get_event(self, resource):
        """Publish and get the event from base station."""
        l_subscribed = False
        this_event = None

        if not self.__subscribed:
            self._get_event_stream()
            self._subscribe_myself()
            l_subscribed = True

        status = self.publish(
            action='get',
            resource=resource,
            mode=None,
            publish_response=False)

        if status == 'success':
            i = 0
            while not this_event and i < 2:
                self.__event_handle.wait(5.0)
                self.__event_handle.clear()
                _LOGGER.debug("Instance %s resource: %s", str(i), resource)
                for event in self.__events:
                    if event['resource'] == resource:
                        this_event = event
                        self.__events.remove(event)
                        break
                i = i + 1

        if l_subscribed:
            self._unsubscribe_myself()
            self._close_event_stream()
            l_subscribed = False

        return this_event
def publish_and_get_event ( self , resource ) : l_subscribed = False this_event = None if not self . __subscribed : self . _get_event_stream ( ) self . _subscribe_myself ( ) l_subscribed = True status = self . publish ( action = 'get' , resource = resource , mode = None , publish_response = False ) if status == 'success' : i = 0 while not this_event and i < 2 : self . __event_handle . wait ( 5.0 ) self . __event_handle . clear ( ) _LOGGER . debug ( "Instance %s resource: %s" , str ( i ) , resource ) for event in self . __events : if event [ 'resource' ] == resource : this_event = event self . __events . remove ( event ) break i = i + 1 if l_subscribed : self . _unsubscribe_myself ( ) self . _close_event_stream ( ) l_subscribed = False return this_event
Publish and get the event from base station.