Example #1
0
def run_graphviz(filename, image, engine="dot"):
    """
    Run :epkg:`GraphViz`.

    @param      filename        filename which contains the graph definition
    @param      image           output image
    @param      engine          *dot* or *neato*
    @return                     output of graphviz
    """
    ext = os.path.splitext(image)[-1]
    if ext != ".png":
        raise Exception("extension should be .png not " + str(ext))
    if sys.platform.startswith("win"):
        bin_ = os.path.dirname(find_graphviz_dot())
        # if bin not in os.environ["PATH"]:
        #    os.environ["PATH"] = os.environ["PATH"] + ";" + bin
        cmd = '"{0}\\{3}" -Tpng "{1}" -o "{2}"'.format(bin_, filename, image,
                                                       engine)
    else:
        cmd = '"{0}" -Tpng "{1}" -o "{2}"'.format(engine, filename, image)
    out, err = run_cmd(cmd, wait=True)
    if len(err) > 0:
        raise Exception(
            "Unable to run Graphviz\nCMD:\n{0}\nOUT:\n{1}\nERR:\n{2}".format(
                cmd, out, err))
    return out
Example #2
0
def run_graphviz(filename, image, engine="dot"):
    """
    Run :epkg:`GraphViz`.

    @param      filename        filename which contains the graph definition
    @param      image           output image
    @param      engine          *dot* or *neato*
    @return                     output of graphviz
    """
    ext = os.path.splitext(image)[-1]
    if ext != ".png":
        raise Exception("extension should be .png not " + str(ext))
    if sys.platform.startswith("win"):
        bin_ = os.path.dirname(find_graphviz_dot())
        # if bin not in os.environ["PATH"]:
        #    os.environ["PATH"] = os.environ["PATH"] + ";" + bin
        cmd = '"{0}\\{3}" -Tpng "{1}" -o "{2}"'.format(
            bin_, filename, image, engine)
    else:
        cmd = '"{0}" -Tpng "{1}" -o "{2}"'.format(engine, filename, image)
    out, err = run_cmd(cmd, wait=True)
    if len(err) > 0:
        raise Exception(
            "unable to run Graphviz\nCMD:\n{0}\nOUT:\n{1}\nERR:\n{2}".format(cmd, out, err))
    return out
def dot_exe():
    """
    retrieve graphivz executable

    @return     filename

    .. versionadded:: 1.1
    """
    r = find_graphviz_dot()
    if r is None:
        raise FileNotFoundError("unable to find graphviz")
    return r
Example #4
0
def dot_exe():
    """
    retrieve graphivz executable

    @return     filename

    .. versionadded:: 1.1
    """
    r = find_graphviz_dot()
    if r is None:
        raise FileNotFoundError("unable to find graphviz")
    return r
Example #5
0
    def test_paths(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        if is_travis_or_appveyor() in ('travis', 'appveyor'):
            return
        exe = find_in_PATH("Microsoft")
        if sys.platform.startswith("win"):
            self.assertTrue(exe is not None)
        else:
            self.assertTrue(exe is None)
        dot = find_graphviz_dot()
        if "dot" not in dot:
            raise Exception('{0}'.format(dot))
        pandoc = find_pandoc_path()
        if sys.platform.startswith("win") and "pandoc" not in pandoc.lower():
            raise Exception('{0}'.format(pandoc))
        latex = find_latex_path()
        if sys.platform.startswith("win") and "latex" not in latex and "miktex" not in latex:
            raise Exception('{0}'.format(latex))
Example #6
0
    def test_paths(self):
        fLOG(__file__,
             self._testMethodName,
             OutputPrint=__name__ == "__main__")

        if is_travis_or_appveyor() in ('travis', 'appveyor'):
            return
        exe = find_in_PATH("Microsoft")
        if sys.platform.startswith("win"):
            self.assertTrue(exe is not None)
        else:
            self.assertTrue(exe is None)
        dot = find_graphviz_dot()
        if "dot" not in dot:
            raise Exception('{0}'.format(dot))
        pandoc = find_pandoc_path()
        if sys.platform.startswith("win") and "pandoc" not in pandoc.lower():
            raise Exception('{0}'.format(pandoc))
        latex = find_latex_path()
        if sys.platform.startswith(
                "win") and "latex" not in latex and "miktex" not in latex:
            raise Exception('{0}'.format(latex))