Exemplo n.º 1
0
def write_source_vc_info(run_source_dir, output=None, popen=None):
    """Write version control information of sources used in run time.

    run_source_dir -- The source directory we are interested in.
    output -- An open file handle or a string containing a writable path.
              If not specified, use sys.stdout.
    popen -- A metomi.rose.popen.RosePopener instance for running vc commands.
             If not specified, use a new local instance.

    """
    if popen is None:
        popen = RosePopener()
    if output is None:
        handle = sys.stdout
    elif hasattr(output, "write"):
        handle = output
    else:
        handle = open(output, "wb")
    msg = "%s\n" % run_source_dir
    write_safely(msg, handle)
    environ = dict(os.environ)
    environ["LANG"] = "C"
    for vcs, args_list in [
        (
            "svn",
            [
                ["info", "--non-interactive"],
                ["status", "--non-interactive"],
                ["diff", "--internal-diff", "--non-interactive"],
            ],
        ),
        ("git", [["describe"], ["status"], ["diff"]]),
    ]:
        if not popen.which(vcs):
            continue
        cwd = os.getcwd()
        os.chdir(run_source_dir)
        try:
            for args in args_list:
                cmd = [vcs] + args
                ret_code, out, _ = popen.run(*cmd, env=environ)
                if out:
                    write_safely(("#" * 80 + "\n"), handle)
                    write_safely(("# %s\n" % popen.list_to_shell_str(cmd)),
                                 handle)
                    write_safely(("#" * 80 + "\n"), handle)
                    write_safely(out, handle)
                if ret_code:  # If cmd fails once, it will likely fail again
                    break
        finally:
            os.chdir(cwd)
Exemplo n.º 2
0
    'cylc.sphinx_ext.diff_selection',
    'cylc.sphinx_ext.grid_table',
    'cylc.sphinx_ext.hieroglyph_patch',
    'cylc.sphinx_ext.hieroglyph_theme_addons',
    'cylc.sphinx_ext.minicylc',
    'cylc.sphinx_ext.practical',
    'cylc.sphinx_ext.rtd_theme_addons',
    'cylc.sphinx_ext.sub_lang',
]

# Select best available SVG image converter.
for svg_converter, extension in [('rsvg', 'sphinxcontrib.rsvgconverter'),
                                 ('inkscape',
                                  'sphinxcontrib.inkscapeconverter')]:
    try:
        assert RosePopener.which(svg_converter)
        __import__(extension)
    except (AssertionError, ImportError):
        # converter or extension not available
        pass
    else:
        extensions.append(extension)
        break
else:
    # no extensions or converters available, fall-back to default
    # vector graphics will be converted to bitmaps in all documents
    extensions.append('sphinx.ext.imgconverter')

# Slide (hieroglyph) settings.
slide_theme = 'single-level'
slide_link_to_html = True