How to use the pybuilder.utils.execute_command function in pybuilder

To help you get started, we’ve selected a few pybuilder examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pybuilder / pybuilder / src / main / python / pybuilder / plugins / python / integrationtest_plugin.py View on Github external
else:
        additional_integrationtest_commandline = ()

    name, _ = os.path.splitext(os.path.basename(test))

    if output_test_names:
        logger.info("Running integration test %s", name)

    env = prepare_environment(project)
    test_time = Timer.start()
    command_and_arguments = (sys.executable, test)
    command_and_arguments += additional_integrationtest_commandline

    report_file_name = os.path.join(reports_dir, name)
    error_file_name = report_file_name + ".err"
    return_code = execute_command(
        command_and_arguments, report_file_name, env, error_file_name=error_file_name)
    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

        if project.get_property("verbose") or project.get_property("integrationtest_always_verbose"):
            print_file_content(report_file_name)
            print_text_line()
            print_file_content(error_file_name)
github pybuilder / pybuilder / src / unittest / python / utils_tests.py View on Github external
def test_execute_command(self, popen, _):
        popen.return_value = Mock()
        popen.return_value.wait.return_value = 0
        self.assertEquals(execute_command(["test", "commands"]), 0)
        self.assertEquals(execute_command(["test", "commands"], outfile_name="test.out"), 0)
        self.assertEquals(
            execute_command(["test", "commands"], outfile_name="test.out", error_file_name="test.out.err"), 0)
github pybuilder / pybuilder / src / unittest / python / utils_tests.py View on Github external
def test_execute_command(self, popen, _):
        popen.return_value = Mock()
        popen.return_value.wait.return_value = 0
        self.assertEquals(execute_command(["test", "commands"]), 0)
        self.assertEquals(execute_command(["test", "commands"], outfile_name="test.out"), 0)
        self.assertEquals(
            execute_command(["test", "commands"], outfile_name="test.out", error_file_name="test.out.err"), 0)
github pybuilder / pybuilder / src / main / python / pybuilder / plugins / python / sphinx_plugin.py View on Github external
def run_sphinx_build(build_command, task_name, logger, project, builder=None):
    logger.info("Running %s" % task_name)
    log_file = project.expand_path("$dir_target", "reports", task_name)

    build_command = [sys.executable, "-m"] + build_command
    if project.get_property("verbose"):
        logger.debug(build_command)

    exit_code = execute_command(build_command, log_file, shell=False)
    if exit_code != 0:
        raise BuildFailedException("Sphinx build command failed. See %s for details.", log_file)
github pybuilder / pybuilder / src / main / python / pybuilder / pluginhelper / external_command.py View on Github external
def run(self, outfile_name):
        error_file_name = "{0}.err".format(outfile_name)
        return_code = execute_command(self.parts, outfile_name)
        error_file_lines = read_file(error_file_name)
        outfile_lines = read_file(outfile_name)

        return ExternalCommandResult(return_code,
                                     outfile_name, outfile_lines,
                                     error_file_name, error_file_lines)
github pybuilder / pybuilder / src / main / python / pybuilder / plugins / python / snakefood_plugin.py View on Github external
def generate_graph(report_file, graph_file):
    execute_command(["sfood-graph", report_file], graph_file)
github pybuilder / pybuilder / src / main / python / pybuilder / plugins / python / python_plugin_helper.py View on Github external
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
github pybuilder / pybuilder / src / main / python / pybuilder / plugins / python / stdeb_plugin.py View on Github external
def run_py2dsc_deb_build(build_command, task_name, logger, project):
    logger.info("Running %s" % task_name)
    log_file = project.expand_path("$dir_target", "reports", task_name)
    if project.get_property("verbose"):
        logger.info(build_command)
        exit_code = execute_command(build_command, log_file, shell=True)
        if exit_code != 0:
            raise BuildFailedException(
                "py2dsc_deb build command failed. See %s for full details:\n%s", log_file, tail_log(log_file))