Example #1
0
def dump_gv_depgraph(root, workdir, tpaths=_TEMPLATE_PATHS, engine=_GV_ENGINE, html=True):
    """
    Generate dependency graph with graphviz.

    TODO: Utilize graph, DAG and trees generated w/ ``dump_graphs``.

    :param root: Root dir where 'var/lib/rpm' exists
    :param workdir: Working dir to dump the result
    :param tpaths: Template path list
    :param engine: Graphviz rendering engine to choose, e.g. neato
    :param html: Generate HTML graph files if True
    """
    reqs = RU.make_requires_dict(root)

    # Set virtual root for root rpms:
    for p, rs in reqs.iteritems():
        if not rs:  # This is a root RPM:
            reqs[p] = ["<rpmlibs>"]  # Set virtual root for this root rpm.

    # Remove self dependency refs:
    ctx = dict(dependencies=[(r, [p for p in ps if p != r]) for r, ps in reqs.iteritems()])

    depgraph_s = RT.render("rpmdep_graph_gv.j2", ctx, tpaths, ask=True)
    src = os.path.join(workdir, "rpmdep_graph.dot")
    U.copen(src, "w").write(depgraph_s)

    output = src + ".svg"
    SH.run("%s -Tsvg -o %s %s" % (engine, output, src), workdir=workdir)

    if html:
        logging.info("Generate HTML files for graphviz outputs")
        for t in ("js/graphviz-svg.js.j2", "js/jquery.js.j2", "rpmdep_graph_gv.html.j2"):
            _renderfile(workdir, t, ctx={}, tpaths=tpaths)
Example #2
0
    def test_20_run__w_permission_denied_error(self):
        if os.getuid() == 0:
            print("Skip this test because you're root.")
            return

        with self.assertRaises(SH.TaskError):
            SH.run("ls /root", stop_on_error=True)
Example #3
0
    def test_30_run__ignore_permission_denied_error(self):
        if os.getuid() == 0:
            print("Skip this test because you're root.")
            return

        self.assertNotEquals(SH.run("ls /root", stop_on_error=False), 0)
Example #4
0
 def test_10_run__timeout(self):
     try:
         self.assertNotEquals(SH.run("sleep 10", timeout=2), 0)
     except OSError:
         pass  # It looks that test failes in docker.
Example #5
0
 def test_00_run(self):
     self.assertEquals(SH.run("true", timeout=10), 0)