示例#1
0
def execute_tool_on_source_files (project, name, command_and_arguments):
    source_dir = project.expand_path("$dir_source_main_python")
    files = discover_files(source_dir, ".py")
    command = as_list(command_and_arguments) + [f for f in files]

    report_file = project.expand_path("$dir_reports/%s" % name)

    return execute_command(command, report_file), report_file
def install_dependency(logger, project, dependency):
    logger.info("Installing dependency '%s'%s", dependency.name, " from %s" % dependency.url if dependency.url else "")
    log_file = project.expand_path("$dir_install_logs", dependency.name)

    pip_command_line = "pip install {0}{1}".format(build_pip_install_options(project), as_pip_argument(dependency))
    exit_code = execute_command(pip_command_line, log_file, shell=True)
    if exit_code != 0:
        raise BuildFailedException("Unable to install dependency '%s'. See %s for details.", dependency.name, log_file)
示例#3
0
def execute_pymetrics (project, logger):
    logger.info("Executing pymetrics on project sources")
    source_dir = project.expand_path("$dir_source_main_python")
    
    files_to_scan = []
    for root, _, files in os.walk(source_dir):
        for file_name in files:
            if file_name.endswith(".py"):
                files_to_scan.append(os.path.join(root, file_name))
    
    csv_file = project.expand_path("$dir_reports/pymetrics.csv")
    
    command = ["pymetrics", "--nosql", "-c", csv_file] + files_to_scan
    
    report_file = project.expand_path("$dir_reports/pymetrics")

    env = {"PYTHONPATH": source_dir}
    execute_command(command, report_file, env=env)
示例#4
0
def execute_tool_on_modules (project, name, command_and_arguments, extend_pythonpath=True):
    source_dir = project.expand_path("$dir_source_main_python")
    modules = discover_modules(source_dir)
    command = as_list(command_and_arguments) + modules

    report_file = project.expand_path("$dir_reports/%s" % name)

    env = os.environ
    if extend_pythonpath:
        env["PYTHONPATH"] = source_dir
    return execute_command(command, report_file, env=env), report_file
def run_single_test(logger, project, reports_dir, test):
    name, _ = os.path.splitext(os.path.basename(test))
    logger.info("Running integration test %s", name)
    env = prepare_environment(project)
    test_time = Timer.start()
    return_code = execute_command((sys.executable, test), os.path.join(reports_dir, name), env)
    test_time.stop()
    report_item = {"test": name, "test_file": test, "time": test_time.get_millis(), "success": True}
    if return_code != 0:
        logger.error("Integration test failed: %s", test)
        report_item["success"] = False

    return report_item