• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utils.execute_command函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pybuilder.utils.execute_command函数的典型用法代码示例。如果您正苦于以下问题:Python execute_command函数的具体用法?Python execute_command怎么用?Python execute_command使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了execute_command函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: collect_dependencies

def collect_dependencies(project, internal_report_file, external_report_file):
    source_dir = project.expand_path("$dir_source_main_python")
    internal_command = ["sfood", "--internal"]
    external_command = ["sfood", "--external"]

    execute_command(internal_command, internal_report_file, cwd=source_dir)
    execute_command(external_command, external_report_file, cwd=source_dir)
开发者ID:0xD3ADB33F,项目名称:pybuilder,代码行数:7,代码来源:snakefood_plugin.py


示例2: test_execute_command

 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)
开发者ID:0xD3ADB33F,项目名称:pybuilder,代码行数:7,代码来源:utils_tests.py


示例3: generate_manpages

def generate_manpages(project, logger):
    """
        Uses the ronn script to convert a markdown source to a gzipped manpage.
    """
    logger.info('Generating manpages')
    try:
        os.makedirs(project.get_property('dir_manpages'))
    except OSError as e:
        if e.errno != errno.EEXIST:
            raise
    ronn_report_file = project.expand_path("$dir_reports/{0}".format('generate_manpage'))
    generate_manpages_command = build_generate_manpages_command(project)
    execute_command(generate_manpages_command, ronn_report_file, shell=True)
开发者ID:B-Rich,项目名称:pybuilder,代码行数:13,代码来源:ronn_manpage_plugin.py


示例4: pip_install

def pip_install(install_targets, index_url=None, extra_index_url=None, upgrade=False, insecure_installs=None,
                force_reinstall=False, target_dir=None, verbose=False, trusted_host=None, constraint_file=None,
                eager_upgrade=False,
                logger=None, outfile_name=None, error_file_name=None, env=None, cwd=None):
    pip_command_line = list()
    pip_command_line.extend(PIP_EXEC_STANZA)
    pip_command_line.append("install")
    pip_command_line.extend(build_pip_install_options(index_url=index_url,
                                                      extra_index_url=extra_index_url,
                                                      upgrade=upgrade,
                                                      insecure_installs=insecure_installs,
                                                      force_reinstall=force_reinstall,
                                                      target_dir=target_dir,
                                                      verbose=verbose,
                                                      trusted_host=trusted_host,
                                                      constraint_file=constraint_file,
                                                      eager_upgrade=eager_upgrade
                                                      ))
    for install_target in as_list(install_targets):
        pip_command_line.extend(as_pip_install_target(install_target))

    if env is None:
        env = os.environ

    if logger:
        logger.debug("Invoking pip: %s", pip_command_line)
    return execute_command(pip_command_line, outfile_name=outfile_name, env=env, cwd=cwd,
                           error_file_name=error_file_name, shell=False)
开发者ID:arcivanov,项目名称:pybuilder,代码行数:28,代码来源:pip_utils.py


示例5: _do_install_dependency

def _do_install_dependency(logger, project, dependency, upgrade, force_reinstall, target_dir, log_file):
    batch = isinstance(dependency, collections.Iterable)

    pip_command_line = list()
    pip_command_line.extend(PIP_EXEC_STANZA)
    pip_command_line.append("install")
    pip_command_line.extend(build_pip_install_options(project.get_property("install_dependencies_index_url"),
                                                      project.get_property("install_dependencies_extra_index_url"),
                                                      upgrade,
                                                      project.get_property(
                                                          "install_dependencies_insecure_installation"),
                                                      force_reinstall,
                                                      target_dir,
                                                      project.get_property("verbose"),
                                                      project.get_property("install_dependencies_trusted_host")
                                                      ))
    pip_command_line.extend(as_pip_install_target(dependency))
    logger.debug("Invoking pip: %s", pip_command_line)
    exit_code = execute_command(pip_command_line, log_file, env=os.environ, shell=False)

    if exit_code != 0:
        if batch:
            dependency_name = " batch dependencies."
        else:
            dependency_name = " dependency '%s'." % dependency.name

        if project.get_property("verbose"):
            print_file_content(log_file)
            raise BuildFailedException("Unable to install%s" % dependency_name)
        else:
            raise BuildFailedException("Unable to install%s See %s for details.",
                                       dependency_name,
                                       log_file)
开发者ID:Dotty280983,项目名称:pybuilder,代码行数:33,代码来源:install_dependencies_plugin.py


示例6: run_single_test

def run_single_test(logger, project, reports_dir, test, ):
    name, _ = os.path.splitext(os.path.basename(test))
    logger.info("Running acceptance test %s", name)
    env = prepare_environment(project)
    test_time = Timer.start()
    command_and_arguments = (sys.executable, test)
    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("acceptance test failed: %s", test)
        report_item["success"] = False

        if project.get_property("verbose"):
            print_file_content(report_file_name)
            print_text_line()
            print_file_content(error_file_name)

    return report_item
开发者ID:zenweasel,项目名称:pybuilder-contrib,代码行数:27,代码来源:run_acceptance_tests.py


示例7: run

    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)
开发者ID:Hawks12,项目名称:pybuilder,代码行数:7,代码来源:external_command.py


示例8: run_sphinx_build

def run_sphinx_build(build_command, task_name, logger, project):
    logger.info("Running %s" % task_name)
    log_file = project.expand_path(
        "$dir_target/reports/{0}".format(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("Sphinx build command failed. See %s for details.", log_file)
开发者ID:010110101001,项目名称:pybuilder,代码行数:9,代码来源:sphinx_plugin.py


示例9: run_py2dsc_deb_build

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))
开发者ID:arcivanov,项目名称:pybuilder,代码行数:9,代码来源:stdeb_plugin.py


示例10: execute_pymetrics

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)
开发者ID:B-Rich,项目名称:pybuilder,代码行数:18,代码来源:pymetrics_plugin.py


示例11: run_sphinx_build

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)
开发者ID:wenlien,项目名称:pybuilder,代码行数:11,代码来源:sphinx_plugin.py


示例12: execute_tool_on_modules

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
开发者ID:B-Rich,项目名称:pybuilder,代码行数:11,代码来源:python_plugin_helper.py


示例13: pdoc_compile_docs

def pdoc_compile_docs(project, logger):
    logger.info("Generating pdoc documentation")

    if not project.get_property("pdoc_module_name"):
        raise BuildFailedException("'pdoc_module_name' must be specified")

    pdoc_command_args = project.get_property("pdoc_command_args", [])
    pdoc_output_dir = project.expand_path("$pdoc_output_dir")

    command_and_arguments = ["pdoc"] + pdoc_command_args
    if "--html" in pdoc_command_args:
        command_and_arguments += ["--html-dir", pdoc_output_dir]
    command_and_arguments += [project.get_property("pdoc_module_name")]

    source_directory = project.expand_path("$pdoc_source")
    environment = {"PYTHONPATH": source_directory,
                   "PATH": os.environ["PATH"]}

    logger.debug("Executing pdoc as: %s", command_and_arguments)
    execute_command(command_and_arguments, outfile_name=project.expand_path("$dir_reports", "pdoc"), env=environment,
                    cwd=pdoc_output_dir)
开发者ID:0xD3ADB33F,项目名称:pybuilder,代码行数:21,代码来源:pdoc_plugin.py


示例14: _install_external_plugin

def _install_external_plugin(name, logger):
    if not name.startswith(PYPI_PLUGIN_PROTOCOL):
        message = "Only plugins starting with '{0}' are currently supported"
        raise MissingPluginException(name, message.format(PYPI_PLUGIN_PROTOCOL))
    plugin_name_on_pypi = name.replace(PYPI_PLUGIN_PROTOCOL, "")
    log_file = tempfile.NamedTemporaryFile(delete=False).name
    result = execute_command(
        "pip install {0}".format(plugin_name_on_pypi), log_file, error_file_name=log_file, shell=True
    )
    if result != 0:
        logger.error("The following pip error was encountered:\n" + "".join(read_file(log_file)))
        message = "Failed to install from PyPI".format(plugin_name_on_pypi)
        raise MissingPluginException(name, message)
开发者ID:shakamunyi,项目名称:pybuilder,代码行数:13,代码来源:pluginloader.py


示例15: install_dependency

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:
        if project.get_property("verbose"):
            print_file_content(log_file)
            raise BuildFailedException("Unable to install dependency '%s'.", dependency.name)
        else:
            raise BuildFailedException("Unable to install dependency '%s'. See %s for details.",
                                       dependency.name,
                                       log_file)
开发者ID:B-Rich,项目名称:pybuilder,代码行数:14,代码来源:install_dependencies_plugin.py


示例16: sphinx_generate

def sphinx_generate(project, logger):
    """Runs sphinx-build against rst sources for the given project.
    """
    logger.info("Running sphinx-build")

    log_file = project.expand_path("$dir_target/reports/{0}".format("sphinx-build"))
    build_command = get_sphinx_build_command(project)

    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("Sphinx build command failed. See %s for details.", log_file)
开发者ID:EHPUA,项目名称:pybuilder,代码行数:14,代码来源:sphinx_plugin.py


示例17: execute_tool_on_source_files

def execute_tool_on_source_files(project, name, command_and_arguments, logger=None, include_test_sources=False):
    files = discover_affected_files(include_test_sources, project)

    command = as_list(command_and_arguments) + [f for f in files]

    report_file = project.expand_path("$dir_reports/{0}".format(name))

    execution_result = execute_command(command, report_file), report_file

    report_file = execution_result[1]
    report_lines = read_file(report_file)

    if project.get_property(name + "_verbose_output") and logger:
        log_report(logger, name, report_lines)

    return execution_result
开发者ID:B-Rich,项目名称:pybuilder,代码行数:16,代码来源:python_plugin_helper.py


示例18: run_single_test

def run_single_test(logger, project, reports_dir, test, output_test_names=True):
    additional_integrationtest_commandline_text = project.get_property("integrationtest_additional_commandline", "")

    if additional_integrationtest_commandline_text:
        additional_integrationtest_commandline = tuple(additional_integrationtest_commandline_text.split(" "))
    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)
            report_item['exception'] = ''.join(read_file(error_file_name)).replace('\'', '')
    elif project.get_property("integrationtest_always_verbose"):
        print_file_content(report_file_name)
        print_text_line()
        print_file_content(error_file_name)

    return report_item
开发者ID:runt18,项目名称:pybuilder,代码行数:44,代码来源:integrationtest_plugin.py


示例19: pip_install

def pip_install(install_targets, index_url=None, extra_index_url=None, upgrade=False, insecure_installs=None,
                force_reinstall=False, target_dir=None, verbose=False, logger=None, outfile_name=None,
                error_file_name=None, env=None, cwd=None):
    pip_command_line = list()
    pip_command_line.append(PIP_EXECUTABLE)
    pip_command_line.append("install")
    pip_command_line.extend(build_pip_install_options(index_url,
                                                      extra_index_url,
                                                      upgrade,
                                                      insecure_installs,
                                                      force_reinstall,
                                                      target_dir,
                                                      verbose
                                                      ))
    for install_target in as_list(install_targets):
        pip_command_line.extend(as_pip_install_target(install_target))

    if logger:
        logger.debug("Invoking pip: %s", pip_command_line)
    return execute_command(pip_command_line, outfile_name=outfile_name, env=env, cwd=cwd,
                           error_file_name=error_file_name, shell=False)
开发者ID:Hawks12,项目名称:pybuilder,代码行数:21,代码来源:pip_utils.py


示例20: install_dependency

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

    if sys.platform.startswith("win"):
        # we can't use quotes on windows
        pip_dependency = as_pip_argument(dependency)
    else:
        # on linux we need quotes because version pinning (>=) would be an IO redirect
        pip_dependency = "'{0}'".format(as_pip_argument(dependency))
    pip_command_line = "pip install {0}{1}".format(build_pip_install_options(project, pip_dependency), pip_dependency)
    exit_code = execute_command(pip_command_line, log_file, shell=True)
    if exit_code != 0:
        if project.get_property("verbose"):
            print_file_content(log_file)
            raise BuildFailedException("Unable to install dependency '%s'.", dependency.name)
        else:
            raise BuildFailedException("Unable to install dependency '%s'. See %s for details.",
                                       getattr(dependency, "name", dependency),
                                       log_file)
开发者ID:AnudeepHemachandra,项目名称:pybuilder,代码行数:22,代码来源:install_dependencies_plugin.py



注:本文中的pybuilder.utils.execute_command函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.Timer类代码示例发布时间:2022-05-25
下一篇:
Python utils.assert_can_execute函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap