def publish_message(topic_name, data):
 pubsub_client = pubsub.Client()
 topic = pubsub_client.topic(topic_name)
 data = data.encode('utf-8')
 message_id = topic.publish(data)
 print 'Message {} published.'.format(message_id)

def publish_message ( topic_name , data ) : pubsub_client = pubsub . Client ( ) topic = pubsub_client . topic ( topic_name ) data = data . encode ( 'utf-8' ) message_id = topic . publish ( data ) print 'Message {} published.' . format ( message_id )
publishes a message to a pub/sub topic with the given data .