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

from retask.task import Task
from retask.queue import Queue

import autocloud
from autocloud.models import init_model, JobDetails
from autocloud.producer import publish_to_fedmsg

import datetime
import json
import logging

log = logging.getLogger("fedmsg")


def produce_jobs(infox):
    """ Queue the jobs into jobqueue
    :args infox: list of dictionaries contains the image url and the buildid
    """
    jobqueue = Queue('jobqueue')
    jobqueue.connect()

    session = init_model()
    timestamp = datetime.datetime.now()
    for info in infox:
        task = Task(info)
        jobqueue.enqueue(task)

        jd = JobDetails(
            taskid=info['buildid'],
            status='q',
            created_on=timestamp,
            user='admin',
            last_updated=timestamp)
        session.add(jd)
        publish_to_fedmsg(topic='image.queued', image_url=info['image_url'],
                          image_name=info['name'], status='queued',
                          buildid=info['buildid'])

    session.commit()


def get_image_url(task_list_output, task_relpath):
    supported_image_ext = ('.qcow2', '.vagrant-libvirt.box')
    url_template = "{file_location}/{file_name}"
    images_list = [f for f in task_list_output if f.endswith(supported_image_ext)]
    if not images_list:
        return None

    file_name = images_list[0]

    # extension to base URL to exact file directory
    full_file_location = autocloud.BASE_KOJI_TASK_URL + task_relpath

    return url_template.format(file_location=full_file_location,
                               file_name=file_name)<commit_msg>create JobDetails entry and pass it in task<commit_after># -*- coding: utf-8 -*-

from retask.task import Task
from retask.queue import Queue

import autocloud
from autocloud.models import init_model, JobDetails
from autocloud.producer import publish_to_fedmsg

import datetime
import json
import logging

log = logging.getLogger("fedmsg")


def produce_jobs(infox):
    """ Queue the jobs into jobqueue
    :args infox: list of dictionaries contains the image url and the buildid
    """
    jobqueue = Queue('jobqueue')
    jobqueue.connect()

    session = init_model()
    timestamp = datetime.datetime.now()
    for info in infox:
        jd = JobDetails(
            taskid=info['buildid'],
            status='q',
            created_on=timestamp,
            user='admin',
            last_updated=timestamp)
        session.add(jd)
        session.commit()

        task = Task(info)
        jobqueue.enqueue(task)

        publish_to_fedmsg(topic='image.queued', image_url=info['image_url'],
                          image_name=info['name'], status='queued',
                          buildid=info['buildid'])



def get_image_url(task_list_output, task_relpath):
    supported_image_ext = ('.qcow2', '.vagrant-libvirt.box')
    url_template = "{file_location}/{file_name}"
    images_list = [f for f in task_list_output if f.endswith(supported_image_ext)]
    if not images_list:
        return None

    file_name = images_list[0]

    # extension to base URL to exact file directory
    full_file_location = autocloud.BASE_KOJI_TASK_URL + task_relpath

    return url_template.format(file_location=full_file_location,
                               file_name=file_name)
{'fraction_non_alphanumeric': 0.09306514560192135, 'fraction_numerical': 0.0018012608826178324, 'mean_word_length': 2.8342922899884924, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5366135', 'n_tokens_mistral': 1018, 'n_tokens_neox': 981, 'n_words': 234}