summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2011-08-08 16:07:14 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2011-08-08 16:07:14 -0400
commite9e0fdf11afe7bd4c24d5512d0d2743ada04e82c (patch)
treed840ff71caca48570e948f6b25a9857afed4d5f2 /src
parentc23d3b238c20a9bedaab8ac3c5ef71b87a1bfb7e (diff)
downloadbcfg2-e9e0fdf11afe7bd4c24d5512d0d2743ada04e82c.tar.gz
bcfg2-e9e0fdf11afe7bd4c24d5512d0d2743ada04e82c.tar.bz2
bcfg2-e9e0fdf11afe7bd4c24d5512d0d2743ada04e82c.zip
invoke dot in a way that works on all systems
Diffstat (limited to 'src')
-rw-r--r--src/lib/Server/Admin/Viz.py18
1 files changed, 14 insertions, 4 deletions
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: