<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def publish_data(self):
 """publish node data if node has updates"""

        self.publish_device_stats()
        publish = self.publish

        # node data
        for node in self.nodes:
            try:
                if node.has_update():
                    for data in node.get_data():
                        publish(*data)
            except NotImplementedError:
                raise
            except Exception as error:
                self.node_error(node, error)