<commit_before>from ConfigParser import Error
from ConfigParser import NoSectionError
from argh import arg
import logging
import os
from pnc_cli import buildconfigurations
from pnc_cli import buildconfigurationsets
from pnc_cli import projects
from pprint import pprint
import random
import string
from tools.config_utils import ConfigReader

@arg('-c', '--config', help='Configuration file to use to drive the build')
@arg('-a', '--artifact', help='Artifact to build')
def make_mead(config="cfg/builder.cfg", artifact=None):
    """
    Create Make Mead configuration
    :param config: Make Mead config name
    :return:
    """    
    if not os.path.isfile(config):
        logging.error('Config file %s not found.', os.path.abspath(config))
        return 1

    try:
        config_reader = ConfigReader(config)
    except NoSectionError as e:
        logging.error('Missing config in %s (%r)', config, e)
        print '-c false'
        return 1
    except Error, err:
        logging.error(err)
        print '-c false'
        return 1

    #pprint (vars(config_reader))
    set = None
    sufix = get_sufix()
    if artifact:
        (subarts, deps_dict) = config_reader.get_dependency_structure(artifact=artifact)
    else:
        (subarts, deps_dict) = config_reader.get_dependency_structure()
        pprint (subarts)
    for subartifact in subarts:
        art_params = config_reader.get_config(subartifact)
        #pprint (art_params)
        artifact = art_params['artifact']
        package = art_params['package']
        version = art_params['version']
        scm_url = art_params['scmURL']
        target = art_params['target']
        (scm_repo_url, scm_revision) = scm_url.split("#", 2)
        artifact_name = package + "-" + version + sufix
        target_name = target + sufix
        if set is None:
            set = buildconfigurationsets.create_build_configuration_set(name=target_name)
            print target_name + ":"
            print set.id
        try:
            project = projects.get_project(name=artifact)        
        except ValueError:
            logging.error('No project ' + artifact)
            return 1
        build_config = buildconfigurations.create_build_configuration(
                                                                      name=artifact_name,
                                                                      project=project.id,
                                                                      environment=1, 
                                                                      scm_repo_url=scm_repo_url,
                                                                      scm_revision=scm_revision,
                                                                      build_script="mvn clean deploy -DskipTests" + get_maven_options(art_params))
        buildconfigurationsets.add_build_configuration_to_set(set_id=set.id, config_id=build_config.id)
        print artifact + ":"
        print build_config.id
    build_record = buildconfigurationsets.build_set(id=set.id)
    #pprint(build_record)

    return config
<commit_msg>Build requires parameter<commit_after>from ConfigParser import Error
from ConfigParser import NoSectionError
from argh import arg
import logging
import os
from pnc_cli import buildconfigurations
from pnc_cli import buildconfigurationsets
from pnc_cli import projects
from pprint import pprint
import random
import string
from tools.config_utils import ConfigReader

@arg('-c', '--config', help='Configuration file to use to drive the build')
@arg('-a', '--artifact', help='Artifact to build')
def make_mead(config="cfg/builder.cfg", artifact=None):
    """
    Create Make Mead configuration
    :param config: Make Mead config name
    :return:
    """    
    if not os.path.isfile(config):
        logging.error('Config file %s not found.', os.path.abspath(config))
        return 1

    try:
        config_reader = ConfigReader(config)
    except NoSectionError as e:
        logging.error('Missing config in %s (%r)', config, e)
        print '-c false'
        return 1
    except Error, err:
        logging.error(err)
        print '-c false'
        return 1

    set = None
    ids = dict()
    sufix = get_sufix()
    (subarts, deps_dict) = config_reader.get_dependency_structure()
    packages = config_reader.get_packages_and_dependencies()
    pprint(packages)
    logging.debug(subarts)
    logging.debug(deps_dict)
    for subartifact in subarts:
        art_params = config_reader.get_config(subartifact)
        logging.debug(art_params)
        artifact = art_params['artifact']
        package = art_params['package']
        version = art_params['version']
        scm_url = art_params['scmURL']
        target = art_params['target']
        (scm_repo_url, scm_revision) = scm_url.split("#", 2)
        artifact_name = package + "-" + version + sufix
        target_name = target + sufix
        if set is None:
            set = buildconfigurationsets.create_build_configuration_set(name=target_name)
            logging.debug(target_name + ":")
            logging.debug(set.id)
        try:
            project = projects.get_project(name=artifact)        
        except ValueError:
            logging.error('No project ' + artifact)
            return 1
        build_config = buildconfigurations.create_build_configuration(
                                                                      name=artifact_name,
                                                                      project=project.id,
                                                                      environment=1, 
                                                                      scm_repo_url=scm_repo_url,
                                                                      scm_revision=scm_revision,
                                                                      build_script="mvn clean deploy -DskipTests" + get_maven_options(art_params))
        buildconfigurationsets.add_build_configuration_to_set(set_id=set.id, config_id=build_config.id)
        ids[artifact] = build_config
        logging.debug(artifact_name + ":")
        logging.debug(build_config.id)
    logging.debug(ids)
    for package, dependencies in packages.iteritems():
        for artifact in dependencies:
            id = ids[package]
            subid = ids[artifact]
            logging.debug(id.id, subid.id)
            buildconfigurations.add_dependency(id=id.id, dependency_id=subid.id)
    build_record = buildconfigurationsets.build_set(id=set.id)

    return build_record

{'fraction_non_alphanumeric': 0.08080654942389327, 'fraction_numerical': 0.0018192844147968466, 'mean_word_length': 1.9359145527369825, 'pattern_counts': {'":': 4, '<': 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': 36, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3056098', 'n_tokens_mistral': 1725, 'n_tokens_neox': 1681, 'n_words': 407}