def get_publisher(self): """ Attempt to get the publisher. """ # Create publisher, if username and password is present if not self.publisher and settings.PULSE_EXCHANGE_NAMESPACE: self.publisher = TreeherderPublisher( namespace=settings.PULSE_EXCHANGE_NAMESPACE, uri=settings.PULSE_URI, schemas=PULSE_SCHEMAS) return self.publisher
from treeherder.model.exchanges import TreeherderPublisher from treeherder.model.pulse_publisher import load_schemas import os # Load schemas for validation of messages published on pulse source_folder = os.path.dirname(os.path.realpath(__file__)) schema_folder = os.path.join(source_folder, '..', '..', 'schemas') schemas = load_schemas(schema_folder) # Create publisher, if username and password is present publisher = None if settings.PULSE_USERNAME and settings.PULSE_PASSWORD: publisher = TreeherderPublisher(client_id=settings.PULSE_USERNAME, access_token=settings.PULSE_PASSWORD, schemas=schemas) @task(name='publish-to-pulse') def publish_to_pulse(project, ids, data_type): # If we don't have a publisher (because of missing configs), then we can't # publish any pulse messages. This is okay, local installs etc. doesn't # need to publish on pulse, and requiring a pulse user is adding more # overhead to an already large development setup process. if not publisher: return jm = JobsModel(project) try: