<commit_before># -*- coding: utf-8 -*-

import fedmsg.consumers
import koji

from autocloud.utils import get_image_url, produce_jobs
import autocloud

import logging
log = logging.getLogger("fedmsg")

DEBUG = autocloud.DEBUG


class AutoCloudConsumer(fedmsg.consumers.FedmsgConsumer):

    if DEBUG:
        topic = 'org.fedoraproject.dev.__main__.buildsys.task.state.change'
    else:
        topic = 'org.fedoraproject.prod.buildsys.task.state.change'

    config_key = 'autocloud.consumer.enabled'

    def __init__(self, *args, **kwargs):
        super(AutoCloudConsumer, self).__init__(*args, **kwargs)

    def _get_tasks(self, builds):
        """ Takes a list of koji createImage task IDs and returns dictionary of
        build ids and image url corresponding to that build ids"""

        _supported_images = ('Fedora-Cloud-Atomic', 'Fedora-Cloud-Base')

        for build in builds:
            log.info('Got Koji build {0}'.format(build))

        # Create a Koji connection to the Fedora Koji instance
        koji_session = koji.ClientSession(autocloud.KOJI_SERVER_URL)

        image_files = []  # list of full URLs of files

        if len(builds) == 1:
            task_result = koji_session.getTaskResult(build[0])
            task_relpath = koji.pathinfo.taskrelpath(int(builds[0]))
            url = get_image_url(task_result.get('files'), task_relpath)
            name = task_result.get('name')
            if url and name in _supported_images:
                data = {
                    'buildid': builds[0],
                    'image_url': url,
                    'name': name
                }
                image_files.append(data)
        elif len(builds) >= 2:
            koji_session.multicall = True
            for build in builds:<commit_msg>minor fix typo in variable<commit_after># -*- coding: utf-8 -*-

import fedmsg.consumers
import koji

from autocloud.utils import get_image_url, produce_jobs
import autocloud

import logging
log = logging.getLogger("fedmsg")

DEBUG = autocloud.DEBUG


class AutoCloudConsumer(fedmsg.consumers.FedmsgConsumer):

    if DEBUG:
        topic = 'org.fedoraproject.dev.__main__.buildsys.task.state.change'
    else:
        topic = 'org.fedoraproject.prod.buildsys.task.state.change'

    config_key = 'autocloud.consumer.enabled'

    def __init__(self, *args, **kwargs):
        super(AutoCloudConsumer, self).__init__(*args, **kwargs)

    def _get_tasks(self, builds):
        """ Takes a list of koji createImage task IDs and returns dictionary of
        build ids and image url corresponding to that build ids"""

        _supported_images = ('Fedora-Cloud-Atomic', 'Fedora-Cloud-Base')

        for build in builds:
            log.info('Got Koji build {0}'.format(build))

        # Create a Koji connection to the Fedora Koji instance
        koji_session = koji.ClientSession(autocloud.KOJI_SERVER_URL)

        image_files = []  # list of full URLs of files

        if len(builds) == 1:
            task_result = koji_session.getTaskResult(builds[0])
            task_relpath = koji.pathinfo.taskrelpath(int(builds[0]))
            url = get_image_url(task_result.get('files'), task_relpath)
            name = task_result.get('name')
            if url and name in _supported_images:
                data = {
                    'buildid': builds[0],
                    'image_url': url,
                    'name': name
                }
                image_files.append(data)
        elif len(builds) >= 2:
            koji_session.multicall = True
            for build in builds:
{'fraction_non_alphanumeric': 0.09955257270693513, 'fraction_numerical': 0.0039149888143176735, 'mean_word_length': 2.371347785108388, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7619931', 'n_tokens_mistral': 1112, 'n_tokens_neox': 1046, 'n_words': 257}