From e9e0fdf11afe7bd4c24d5512d0d2743ada04e82c Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Mon, 8 Aug 2011 16:07:14 -0400 Subject: invoke dot in a way that works on all systems --- src/lib/Server/Admin/Viz.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/lib/Server/Admin') diff --git a/src/lib/Server/Admin/Viz.py b/src/lib/Server/Admin/Viz.py index fe6a8a7c2..2c618634a 100644 --- a/src/lib/Server/Admin/Viz.py +++ b/src/lib/Server/Admin/Viz.py @@ -87,11 +87,21 @@ class Viz(Bcfg2.Server.Admin.MetadataCore): else: format = 'png' - cmd = ["dot", "-T", pipes.quote(format)] + cmd = ["dot", "-T", format] if output: - cmd.extend(["-o", pipes.quote(output)]) - dotpipe = Popen(cmd, - shell=True, stdin=PIPE, stdout=PIPE, close_fds=True) + cmd.extend(["-o", output]) + try: + dotpipe = Popen(cmd, stdin=PIPE, stdout=PIPE, close_fds=True) + except OSError: + # on some systems (RHEL 6), you cannot run dot with + # shell=True. on others (Gentoo with Python 2.7), you + # must. In yet others (RHEL 5), either way works. I have + # no idea what the difference is, but it's kind of a PITA. + cmd = ["dot", "-T", pipes.quote(format)] + if output: + cmd.extend(["-o", pipes.quote(output)]) + dotpipe = Popen(cmd, shell=True, + stdin=PIPE, stdout=PIPE, close_fds=True) try: dotpipe.stdin.write("digraph groups {\n") except: -- cgit v1.2.3-1-g7c22