Example #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 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)
Example #2
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 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")
    handle.write("%s\n" % run_source_dir)
    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:
                    handle.write("#" * 80 + "\n")
                    handle.write(("# %s\n" % popen.list_to_shell_str(cmd)))
                    handle.write("#" * 80 + "\n")
                    handle.write(out)
                if ret_code:  # If cmd fails once, it will likely fail again
                    break
        finally:
            os.chdir(cwd)
Example #3
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 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")
    environ = dict(os.environ)
    environ["LANG"] = "C"
    for vcs, cmds in [("svn", ["info", "status", "diff"]),
                      ("git", ["describe", "status", "diff"])]:
        if not popen.which(vcs):
            continue
        cwd = os.getcwd()
        os.chdir(run_source_dir)
        try:
            for cmd in cmds:
                rc, out, err = popen.run(vcs, cmd, env=environ)
                if out:
                    handle.write("#" * 80 + "\n")
                    handle.write(("# %s %s\n" % (vcs, cmd)).upper())
                    handle.write("#" * 80 + "\n")
                    handle.write(out)
                if rc: # If cmd fails once, chances are, it will fail again
                    break
        finally:
            os.chdir(cwd)
Example #4
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 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")
    for vcs, cmds in [("svn", ["info", "status", "diff"]),
                      ("git", ["describe", "status", "diff"])]:
        if not popen.which(vcs):
            continue
        cwd = os.getcwd()
        os.chdir(run_source_dir)
        try:
            for cmd in cmds:
                rc, out, err = popen.run(vcs, cmd)
                if out:
                    handle.write("#" * 80 + "\n")
                    handle.write(("# %s %s\n" % (vcs, cmd)).upper())
                    handle.write("#" * 80 + "\n")
                    handle.write(out)
                if rc: # If cmd fails once, chances are, it will fail again
                    break
        finally:
            os.chdir(cwd)
Example #5
0
    'auto_cli_doc',
    'cylc_lang',
    'minicylc',
    'practical',
    'rose_lang',
    'rose_domain',
    'script_include',
    '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
Example #6
0
    'auto_cli_doc',
    'cylc_lang',
    'minicylc',
    'practical',
    'rose_lang',
    'rose_domain',
    'script_include',
    '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