"""
This module is currently an experiment in publishing messages to pulse.

It might become a real pulse publisher one day.
"""
import os
import sys

from pulse_actions.authentication import (
    get_user_and_password,
    AuthenticationError
)

from mozillapulse.publishers import GenericPublisher
from mozillapulse.config import PulseConfiguration
from mozillapulse.messages.base import GenericMessage


class ExperimentalPublisher(GenericPublisher):
    def __init__(self, **kwargs):
        super(ExperimentalPublisher, self).__init__(
            PulseConfiguration(**kwargs),
            'exchange/adusca/experiment',
            **kwargs)


class MessageHandler:

    def __init__(self):
        """Create Publisher."""
        try:
            user, password = get_user_and_password()
        except AuthenticationError as e:
            print(e.message)
            sys.exit(1)

        self.publisher = ExperimentalPublisher(user=user, password=password)

    def publish_message(self, data, routing_key):
        """Publish a message to exchange/adusca/experiment."""
        msg = GenericMessage()
        msg.routing_parts = routing_key.split('.')
        for key, value in data.iteritems():
            msg.set_data(key, value)
        try:
            self.publisher.publish(msg)
        except Exception as e:
            print('ERROR: We failed to post a pulse message with what we did')
            print(e.message)

@@ -126,18 +126,8 @@
 %22%22%22%0A
-import os%0A
 impo
@@ -460,16 +460,22 @@
 __(self,
+ user,
  **kwarg
@@ -599,26 +599,38 @@
 nge/
-adusca/experiment'
+%25s/pulse_actions' %25 pulse_user
 ,%0A  
@@ -796,16 +796,114 @@
 sword()%0A
+            self.publisher = ExperimentalPublisher(%0A                user=user, password=password)%0A
         
@@ -988,25 +988,24 @@
 exit(1)%0A
-%0A
         
 self.pub
@@ -1000,75 +1000,188 @@
     
-self.publisher = ExperimentalPublisher(user=user, password=password
+except Exception as e:%0A            # We continue without posting to pulse%0A            print('ERROR: We failed to post a pulse message with what we did')%0A            print(e.message
 )%0A%0A 
@@ -1274,25 +1274,35 @@
 nge/
-adusca/experiment
+$%7Bpulse_user%7D/pulse_actions
 .%22%22%22
@@ -1465,33 +1465,16 @@
  value)%0A
-        try:%0A    
         
@@ -1505,143 +1505,4 @@
 sg)%0A
-        except Exception as e:%0A            print('ERROR: We failed to post a pulse message with what we did')%0A            print(e.message)%0A

Remove hardcoded publishing user