Exemplo n.º 1
0
    def __init__(self, configfile, pulse_authfile, debug, log_folder, logger,
                 message=None, display_only=False):

        self.config = JSONFile(configfile).read()
        self.debug = debug
        self.log_folder = log_folder
        self.logger = logger
        self.display_only = display_only
        self.message = message

        self.jenkins = jenkins.Jenkins(self.config['jenkins']['url'],
                                       self.config['jenkins']['auth']['username'],
                                       self.config['jenkins']['auth']['password'])

        # Setup Pulse listeners
        self.load_pulse_config(pulse_authfile)
        queue_name = 'queue/{user}/{host}/{type}'.format(user=self.pulse_auth['user'],
                                                         host=socket.getfqdn(),
                                                         type=self.config['pulse']['applabel'])

        # Queue for build notifications
        queue_builds = NormalizedBuildQueue(name='{}_build'.format(queue_name),
                                            callback=self.process_build,
                                            pulse_config=self.config['pulse'])

        # Queue for update notifications
        queue_updates = FunsizeTaskCompletedQueue(name='{}_update'.format(queue_name),
                                                  callback=self.process_build,
                                                  pulse_config=self.config['pulse'])

        # When a local message is used, process it and return immediately
        if self.message:
            data = JSONFile(self.message).read()

            # Check type of message and let it process by the correct queue
            if data.get('ACCEPTED_MAR_CHANNEL_IDS'):
                queue_updates.process_message(data, None)
            else:
                queue_builds.process_message(data, None)
            return

        with lib.PulseConnection(userid=self.pulse_auth['user'],
                                 password=self.pulse_auth['password']) as connection:
            consumer = lib.PulseConsumer(connection)

            try:
                consumer.add_queue(queue_builds)
                consumer.add_queue(queue_updates)

                consumer.run()
            except KeyboardInterrupt:
                self.logger.info('Shutting down Pulse listener')
Exemplo n.º 2
0
    def __init__(self,
                 configfile,
                 authfile,
                 treeherder_configfile,
                 debug,
                 log_folder,
                 logger,
                 message=None,
                 display_only=False):

        self.config = JSONFile(configfile).read()
        self.debug = debug
        self.log_folder = log_folder
        self.logger = logger
        self.display_only = display_only
        self.message = message
        self.treeherder_config = {}

        self.load_authentication_config(authfile)

        self.jenkins = jenkins.Jenkins(
            self.authentication['jenkins']['url'],
            self.authentication['jenkins']['user'],
            self.authentication['jenkins']['password'])

        # Setup Pulse listeners
        queue_name = 'queue/{user}/{host}/{type}'.format(
            user=self.authentication['pulse']['user'],
            host=socket.getfqdn(),
            type=self.config['pulse']['applabel'])

        # Load settings from the Treeherder config file
        with open(treeherder_configfile, 'r') as f:
            for line in f.readlines():
                if line.strip() and not line.startswith('#'):
                    key, value = line.strip().split('=')
                    self.treeherder_config.update({key: value})

        # Queue for build notifications
        queue_builds = NormalizedBuildQueue(name='{}_build'.format(queue_name),
                                            callback=self.process_build,
                                            pulse_config=self.config['pulse'])

        # Queue for release build notifications
        queue_release_builds = ReleaseTaskCompletedQueue(
            name='{}_build_release'.format(queue_name),
            callback=self.process_build,
            pulse_config=self.config['pulse'])

        # Queue for update notifications
        queue_updates = FunsizeTaskCompletedQueue(
            name='{}_update'.format(queue_name),
            callback=self.process_build,
            pulse_config=self.config['pulse'])

        # When a local message is used, process it and return immediately
        if self.message:
            data = JSONFile(self.message).read()

            # Check type of message and let it process by the correct queue
            if data.get('ACCEPTED_MAR_CHANNEL_IDS'):
                queue_updates.process_message(data, None)
            elif data.get('tags'):
                queue_builds.process_message(data, None)
            else:
                queue_release_builds.process_message(data, None)

            return

        with lib.PulseConnection(userid=self.authentication['pulse']['user'],
                                 password=self.authentication['pulse']
                                 ['password']) as connection:
            consumer = lib.PulseConsumer(connection)

            try:
                consumer.add_queue(queue_builds)
                consumer.add_queue(queue_release_builds)
                consumer.add_queue(queue_updates)

                consumer.run()
            except KeyboardInterrupt:
                self.logger.info('Shutting down Pulse listener')
Exemplo n.º 3
0
    def __init__(self, configfile, authfile, treeherder_configfile, debug,
                 log_folder, logger, message=None, display_only=False):

        self.config = JSONFile(configfile).read()
        self.debug = debug
        self.log_folder = log_folder
        self.logger = logger
        self.display_only = display_only
        self.message = message
        self.treeherder_config = {}

        self.load_authentication_config(authfile)

        self.jenkins = jenkins.Jenkins(self.authentication['jenkins']['url'],
                                       self.authentication['jenkins']['user'],
                                       self.authentication['jenkins']['password'])

        # Setup Pulse listeners
        queue_name = 'queue/{user}/{host}/{type}'.format(user=self.authentication['pulse']['user'],
                                                         host=socket.getfqdn(),
                                                         type=self.config['pulse']['applabel'])

        # Load settings from the Treeherder config file
        with open(treeherder_configfile, 'r') as f:
            for line in f.readlines():
                if line.strip() and not line.startswith('#'):
                    key, value = line.strip().split('=')
                    self.treeherder_config.update({key: value})

        # Queue for build notifications
        queue_builds = NormalizedBuildQueue(
            name='{}_build'.format(queue_name),
            callback=self.process_build,
            pulse_config=self.config['pulse']
        )

        # Queue for release build notifications
        queue_release_builds = ReleaseTaskCompletedQueue(
            name='{}_build_release'.format(queue_name),
            callback=self.process_build,
            pulse_config=self.config['pulse'])

        # Queue for update notifications
        queue_updates = FunsizeTaskCompletedQueue(
            name='{}_update'.format(queue_name),
            callback=self.process_build,
            pulse_config=self.config['pulse']
        )

        # When a local message is used, process it and return immediately
        if self.message:
            data = JSONFile(self.message).read()

            # Check type of message and let it process by the correct queue
            if data.get('ACCEPTED_MAR_CHANNEL_IDS'):
                queue_updates.process_message(data, None)
            elif data.get('tags'):
                queue_builds.process_message(data, None)
            else:
                queue_release_builds.process_message(data, None)

            return

        with lib.PulseConnection(userid=self.authentication['pulse']['user'],
                                 password=self.authentication['pulse']['password']) as connection:
            consumer = lib.PulseConsumer(connection)

            try:
                consumer.add_queue(queue_builds)
                consumer.add_queue(queue_release_builds)
                consumer.add_queue(queue_updates)

                consumer.run()
            except KeyboardInterrupt:
                self.logger.info('Shutting down Pulse listener')