当前位置: 首页>>代码示例>>Python>>正文


Python Popen.rpartition方法代码示例

本文整理汇总了Python中subprocess.Popen.rpartition方法的典型用法代码示例。如果您正苦于以下问题:Python Popen.rpartition方法的具体用法?Python Popen.rpartition怎么用?Python Popen.rpartition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在subprocess.Popen的用法示例。


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

示例1: prepare

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import rpartition [as 别名]
def prepare(globs, locs):
    git = Popen('which git 2> %s' % os.devnull, shell=True, stdout=PIPE
                ).stdout.read().strip()
    cwd = os.getcwd()
    root = os.path.abspath(os.path.join(cwd, '..', '..'))
    print "Running from %s..." % (root, )

    buildenv = os.path.join(root, 'vendor', 'erebot', 'buildenv')

    origin = Popen([git, 'config', '--local', 'remote.origin.url'],
                   stdout=PIPE).stdout.read().strip()
    project = origin.rpartition('/')[2]
    if project.endswith('.git'):
        project = project[:-4]
    locs['project'] = project

    for repository, path in (
        ('git://github.com/Erebot/Erebot_Buildenv.git', buildenv),
    ):
        if not os.path.isdir(path):
            os.makedirs(path)
            print "Cloning %s into %s..." % (repository, path)
            call([git, 'clone', repository, path])
        else:
            os.chdir(path)
            print "Updating clone of %s in %s..." % (repository, path)
            call([git, 'checkout', 'master'])
            call([git, 'pull'])
            os.chdir(cwd)

    real_conf = os.path.join(buildenv, 'sphinx', 'conf.py')
    print "Including real configuration file (%s)..." % (real_conf, )
    execfile(real_conf, globs, locs)
开发者ID:mario-bros,项目名称:Plop,代码行数:35,代码来源:conf.py

示例2: prepare

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import rpartition [as 别名]
def prepare(globs, locs):
    # Where are we?
    cwd = os.getcwd()
    root = os.path.abspath(os.path.join(cwd, "..", ".."))

    git = Popen("which git 2> %s" % os.devnull, shell=True, stdout=PIPE).stdout.read().strip()
    doxygen = Popen("which doxygen 2> %s" % os.devnull, shell=True, stdout=PIPE).stdout.read().strip()

    locs["rtd_slug"] = os.path.basename(os.path.dirname(os.path.dirname(root)))
    locs["rtd_version"] = os.path.basename(root)
    pybabel = os.path.join(root, "..", "..", "envs", locs["rtd_version"], "bin", "pybabel")

    print "git version:"
    call([git, "--version"])
    print "doxygen version:"
    call([doxygen, "--version"])
    print "pybabel version:"
    call([pybabel, "--version"])

    print "Building version %s for %s in %s..." % (locs["rtd_version"], locs["rtd_slug"], root)
    os.chdir(root)

    # Figure several configuration values from git.
    origin = Popen([git, "config", "--local", "remote.origin.url"], stdout=PIPE).stdout.read().strip()
    git_tag = Popen(["git", "describe", "--tags", "--exact", "--first-parent"], stdout=PIPE).communicate()[0].strip()
    project = origin.rpartition("/")[2]
    if project.endswith(".git"):
        project = project[:-4]
    os.environ["SPHINX_PROJECT"] = project
    if git_tag:
        os.environ["SPHINX_VERSION"] = git_tag
        os.environ["SPHINX_RELEASE"] = git_tag
    else:
        commit = Popen(["git", "describe", "--always", "--first-parent"], stdout=PIPE).communicate()[0].strip()
        os.environ["SPHINX_VERSION"] = "latest"
        os.environ["SPHINX_RELEASE"] = "latest-%s" % (commit,)
        locs["tags"].add("devel")

    # Clone or update dependencies
    buildenv = os.path.join(root, "vendor", "erebot", "buildenv")
    natives = os.path.join(root, "vendor", "fpoirotte", "natives4doxygen")
    generic_doc = os.path.join(root, "docs", "src", "generic")
    for repository, path in (
        ("git://github.com/Erebot/Buildenv.git", buildenv),
        ("git://github.com/fpoirotte/PHPNatives4Doxygen", natives),
        ("git://github.com/Erebot/GenericDoc.git", generic_doc),
    ):
        if not os.path.isdir(path):
            os.makedirs(path)
            print "Cloning %s into %s..." % (repository, path)
            call([git, "clone", repository, path])
        else:
            os.chdir(path)
            print "Updating clone of %s in %s..." % (repository, path)
            call([git, "checkout", "master"])
            call([git, "pull"])
            os.chdir(root)

    composer = json.load(open(os.path.join(root, "composer.json"), "r"))

    # Run doxygen
    call(
        [doxygen, os.path.join(root, "Doxyfile")],
        env={
            "COMPONENT_NAME": os.environ["SPHINX_PROJECT"],
            "COMPONENT_VERSION": os.environ["SPHINX_VERSION"],
            "COMPONENT_BRIEF": composer.get("description", ""),
        },
    )

    # Remove extra files/folders.
    try:
        shutil.rmtree(os.path.join(root, "build"))
    except OSError:
        pass
    shutil.move(os.path.join(root, "docs", "api", "html"), os.path.join(root, "build", "apidoc"))
    try:
        shutil.move(
            os.path.join(root, "%s.tagfile.xml" % os.environ["SPHINX_PROJECT"]),
            os.path.join(root, "build", "apidoc", "%s.tagfile.xml" % os.environ["SPHINX_PROJECT"]),
        )
    except OSError:
        pass

    # Copy translations for generic docs to catalogs folder.
    gen_i18n = os.path.join(root, "docs", "src", "generic", "i18n", ".")[:-1]
    for translation in glob.iglob(os.path.join(gen_i18n, "*")):
        target_dir = os.path.join(root, "docs", "i18n", translation[len(gen_i18n) :], "LC_MESSAGES", "generic")
        translation = os.path.join(translation, "LC_MESSAGES", "generic")
        shutil.rmtree(target_dir, ignore_errors=True)
        shutil.copytree(translation, target_dir)

    # Compile translation catalogs.
    for locale_dir in glob.iglob(os.path.join(root, "docs", "i18n", "*")):
        for root, dirnames, filenames in os.walk(locale_dir):
            for po in fnmatch.filter(filenames, "*.po"):
                po = os.path.join(root, po)
                mo = po[:-3] + ".mo"
                call([pybabel, "compile", "-f", "--statistics", "-i", po, "-o", mo])

#.........这里部分代码省略.........
开发者ID:erebot,项目名称:erebot,代码行数:103,代码来源:conf.py


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