<commit_before>"""
PyBuilder configuration file
"""

from pybuilder.core import use_plugin, after, init, task, description
from pybuilder.utils import assert_can_execute, execute_command, read_file
from pybuilder.plugins.python.python_plugin_helper import log_report
from pybuilder.errors import BuildFailedException
from pybuilder.pluginhelper.external_command import ExternalCommandBuilder


import os
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
WEBAPP_DIR = os.path.join(BASE_DIR, 'src', 'main', 'webapp')


use_plugin("analysis")
use_plugin('python.core')
use_plugin('python.unittest')
use_plugin('python.coverage')
use_plugin('python.flake8')
use_plugin('python.install_dependencies')
use_plugin('pypi:pybuilder_django_enhanced_plugin')

default_task = ['clean', 'install_dependencies', 'django_makemigrations', 'django_migrate', 'django_test', 'grunt', 'analyze', 'publish']

@init
def initialize(project):
    project.set_property('install_dependencies_upgrade', True)
    project.depends_on_requirements('requirements.txt')
    project.build_depends_on_requirements('requirements_dev.txt')

    project.set_property('django_project', 'opendatahub')
    project.set_property('django_apps', ['hub'])


    project.set_property('coverage_break_build', False)
    project.set_property('flake8_include_test_sources', True)
    project.set_property('flake8_break_build', True)
    project.set_property('flake8_verbose_output', True)

    # F401: Unused import
    # E501: long line
    # E128: visual indent
    project.set_property('flake8_ignore', 'F401,E501,E128')
    project.set_property('flake8_max_line_length', 160)




def custom_exec(project, logger, args, name=None, cwd=None, fail_error=True):
    cmd = args[0]
    name = name or cmd
    logger.debug('Checking availability of ' + cmd)
    assert_can_execute((cmd,), cmd, 'plugin opendatahub.' + name)
    logger.debug(name + ' has been found')

    report_file = project.expand_path('$dir_reports/{0}'.format('bower'))
    error_report_file = '{0}.err'.format(report_file)

    exit_code = execute_command(args, report_file, cwd=cwd)
    report_lines = read_file(report_file)
    error_report_lines = read_file(error_report_file)

    verbose = project.get_property('verbose')
    if error_report_lines:
        msg = 'Errors while running {0}, see {1}'.format(name, error_report_file)
        if verbose:
            logger.info(''.join(error_report_lines))
        if fail_error:
            raise BuildFailedException(msg)

    if verbose:
        logger.info(''.join(report_lines))



@task('install_runtime_dependencies')
def install_bower_packages(project, logger):
    custom_exec(project, logger, ['bower', 'install', '--config.analytics=false', '--allow-root', '--no-interactive'], cwd=WEBAPP_DIR)


@task('install_build_dependencies')
def install_bower_packages(project, logger):
    custom_exec(project, logger, ['npm', 'install'], cwd=WEBAPP_DIR, fail_error=False)


@task('grunt')
@after(('run_unit_tests',), only_once=True)
def install_bower_packages(project, logger):
    custom_exec(project, logger, ['grunt'], cwd=WEBAPP_DIR, fail_error=True)


@task('django_migrate')
def django_migrate_fix(project, logger):
    from pybuilder_django_enhanced_plugin.tasks.common import run_django_manage_command

    args = ['migrate']
    command_result = run_django_manage_command(project, logger, 'django_migrate', args)
    if command_result.exit_code != 0:
        error_message = ''.join(command_result.error_report_lines)
        logger.error('Django migrate failed: {}'.format(error_message))
        raise BuildFailedException('Django migrate failed')
    return command_result

<commit_msg>attempt to fix deployment<commit_after>"""
PyBuilder configuration file
"""

from pybuilder.core import use_plugin, after, init, task, description, depends
from pybuilder.utils import assert_can_execute, execute_command, read_file
from pybuilder.plugins.python.python_plugin_helper import log_report
from pybuilder.errors import BuildFailedException
from pybuilder.pluginhelper.external_command import ExternalCommandBuilder


import os
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
WEBAPP_DIR = os.path.join(BASE_DIR, 'src', 'main', 'webapp')


use_plugin("analysis")
use_plugin('python.core')
use_plugin('python.unittest')
use_plugin('python.coverage')
use_plugin('python.flake8')
use_plugin('python.install_dependencies')
use_plugin('pypi:pybuilder_django_enhanced_plugin')

default_task = ['clean', 'install_dependencies', 'django_makemigrations', 'django_migrate', 'django_test', 'grunt', 'analyze', 'publish']

@init
def initialize(project):
    project.set_property('install_dependencies_upgrade', True)
    project.depends_on_requirements('requirements.txt')
    project.build_depends_on_requirements('requirements_dev.txt')

    project.set_property('django_project', 'opendatahub')
    project.set_property('django_apps', ['hub'])


    project.set_property('coverage_break_build', False)
    project.set_property('flake8_include_test_sources', True)
    project.set_property('flake8_break_build', True)
    project.set_property('flake8_verbose_output', True)

    # F401: Unused import
    # E501: long line
    # E128: visual indent
    project.set_property('flake8_ignore', 'F401,E501,E128')
    project.set_property('flake8_max_line_length', 160)




def custom_exec(project, logger, args, name=None, cwd=None, fail_error=True):
    cmd = args[0]
    name = name or cmd
    logger.debug('Checking availability of ' + cmd)
    assert_can_execute((cmd,), cmd, 'plugin opendatahub.' + name)
    logger.debug(name + ' has been found')

    report_file = project.expand_path('$dir_reports/{0}'.format('bower'))
    error_report_file = '{0}.err'.format(report_file)

    exit_code = execute_command(args, report_file, cwd=cwd)
    report_lines = read_file(report_file)
    error_report_lines = read_file(error_report_file)

    verbose = project.get_property('verbose')
    if error_report_lines:
        msg = 'Errors while running {0}, see {1}'.format(name, error_report_file)
        if verbose:
            logger.info(''.join(error_report_lines))
        if fail_error:
            raise BuildFailedException(msg)

    if verbose:
        logger.info(''.join(report_lines))



@task('install_runtime_dependencies')
def install_bower_packages(project, logger):
    custom_exec(project, logger, ['bower', 'install', '--config.analytics=false', '--allow-root', '--no-interactive'], cwd=WEBAPP_DIR)


@task('install_build_dependencies')
def install_npm_packages(project, logger):
    custom_exec(project, logger, ['npm', 'install'], cwd=WEBAPP_DIR, fail_error=False)


@task
@after(('run_unit_tests',), only_once=True)
def grunt(project, logger):
    custom_exec(project, logger, ['grunt'], cwd=WEBAPP_DIR, fail_error=True)


@task('django_migrate')
def django_migrate_fix(project, logger):
    from pybuilder_django_enhanced_plugin.tasks.common import run_django_manage_command

    args = ['migrate']
    command_result = run_django_manage_command(project, logger, 'django_migrate', args)
    if command_result.exit_code != 0:
        error_message = ''.join(command_result.error_report_lines)
        logger.error('Django migrate failed: {}'.format(error_message))
        raise BuildFailedException('Django migrate failed')
    return command_result


{'fraction_non_alphanumeric': 0.12256835804652429, 'fraction_numerical': 0.008978370289756496, 'mean_word_length': 5.689717925386716, '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': '386184', 'n_tokens_mistral': 2407, 'n_tokens_neox': 2303, 'n_words': 424}