Exemple #1
0
    def publish(self, message):
        # Do basic type checking
        self.basic_type_check(message, self.publish_msg_fields)
        topic = message["topic"]
        latch = message.get("latch", False)
        queue_size = message.get("queue_size", 100)

        if Publish.topics_glob is not None and Publish.topics_glob:
            self.protocol.log("debug", "Topic security glob enabled, checking topic: " + topic)
            match = False
            for glob in Publish.topics_glob:
                if (fnmatch.fnmatch(topic, glob)):
                    self.protocol.log("debug", "Found match with glob " + glob + ", continuing publish...")
                    match = True
                    break
            if not match:
                self.protocol.log("warn", "No match found for topic, cancelling publish to: " + topic)
                return
        else:
            self.protocol.log("debug", "No topic security glob, not checking publish.")

        # Register as a publishing client, propagating any exceptions
        client_id = self.protocol.client_id
        manager.register(client_id, topic, latch=latch, queue_size=queue_size)
        self._published[topic] = True

        # Get the message if one was provided
        msg = message.get("msg", {})

        # Publish the message
        manager.publish(client_id, topic, msg, latch=latch, queue_size=queue_size)
Exemple #2
0
    def publish(self, message):
        # Do basic type checking
        self.basic_type_check(message, self.publish_msg_fields)
        topic = message["topic"]
        latch = message.get("latch", False)
        queue_size = message.get("queue_size", 100)

        if Publish.topics_glob is not None and Publish.topics_glob:
            self.protocol.log("debug", "Topic security glob enabled, checking topic: " + topic)
            match = False
            for glob in Publish.topics_glob:
                if (fnmatch.fnmatch(topic, glob)):
                    self.protocol.log("debug", "Found match with glob " + glob + ", continuing publish...")
                    match = True
                    break
            if not match:
                self.protocol.log("warn", "No match found for topic, cancelling publish to: " + topic)
                return
        else:
            self.protocol.log("debug", "No topic security glob, not checking publish.")

        # Register as a publishing client, propagating any exceptions
        client_id = self.protocol.client_id
        manager.register(client_id, topic, latch=latch, queue_size=queue_size)
        self._published[topic] = True

        # Get the message if one was provided
        msg = message.get("msg", {})

        # Publish the message
        manager.publish(client_id, topic, msg, latch=latch, queue_size=queue_size)
    def publish(self, message):
        # Do basic type checking
        self.basic_type_check(message, self.publish_msg_fields)
        topic = message["topic"]
        latch = message.get("latch", False)
        queue_size = message.get("queue_size", 100)

        if Publish.topics_glob is not None and Publish.topics_glob:
            self.protocol.log("debug", "Topic security glob enabled, checking topic: " + topic)
            match = False
            for glob in Publish.topics_glob:
                if (fnmatch.fnmatch(topic, glob)):
                    self.protocol.log("debug", "Found match with glob " + glob + ", continuing publish...")
                    match = True
                    break
            if not match:
                self.protocol.log("warn", "No match found for topic, cancelling publish to: " + topic)
                return
        else:
            self.protocol.log("debug", "No topic security glob, not checking publish.")

        if self.is_permitted(topic,
                             self.protocol.advertisement_wl,
                             self.protocol.advertisement_bl):
            # Register as a publishing client, propagating any exceptions
            client_id = self.protocol.client_id
            manager.register(client_id, topic, latch=latch, queue_size=queue_size)
            self._published[topic] = True
        	# Publish the message
            manager.publish(client_id, topic, msg, latch=latch, queue_size=queue_size)
        else:
            rospy.logwarn("dropping publishing of topic because it is invalid: %s not allowed", topic)
Exemple #4
0
    def publish(self, message):
        # Do basic type checking
        self.basic_type_check(message, self.publish_msg_fields)
        topic = message["topic"]

        # Register as a publishing client, propagating any exceptions
        client_id = self.protocol.client_id
        manager.register(client_id, topic)
        self._published[topic] = True

        # Get the message if one was provided
        msg = message.get("msg", {})

        # Publish the message
        manager.publish(client_id, topic, msg)
    def publish(self, message):
        # Do basic type checking
        self.basic_type_check(message, self.publish_msg_fields)
        topic = message["topic"]
        latch = message.get("latch", False)
        queue_size = message.get("queue_size", 100)

        # Register as a publishing client, propagating any exceptions
        client_id = self.protocol.client_id
        manager.register(client_id, topic, latch=latch, queue_size=queue_size)
        self._published[topic] = True

        # Get the message if one was provided
        msg = message.get("msg", {})

        # Publish the message
        manager.publish(client_id, topic, msg, latch=latch, queue_size=queue_size)