summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Douard <david.douard@logilab.fr>2014-09-01 12:42:16 +0200
committerDavid Douard <david.douard@logilab.fr>2014-09-01 12:42:16 +0200
commit6d7b9a64ec4547d9a82fec7ee857c68c26bfbf7d (patch)
tree81877ef3067f9505f54bed9b270c5271cb55c24b
parent381fe9c73ff45b5bb958e55b67880fd2c0f766e8 (diff)
downloadlogilab-common-6d7b9a64ec4547d9a82fec7ee857c68c26bfbf7d.tar.gz
[graph] More explicit error message if dot is not found (closes #253516)
-rw-r--r--graph.py20
1 files changed, 13 insertions, 7 deletions
diff --git a/graph.py b/graph.py
index 9a77495..686a6ce 100644
--- a/graph.py
+++ b/graph.py
@@ -29,6 +29,7 @@ import os
import sys
import tempfile
import codecs
+import errno
def escape(value):
"""Make <value> usable in a dot file."""
@@ -114,13 +115,18 @@ class DotBackend:
use_shell = True
else:
use_shell = False
- if mapfile:
- subprocess.call([self.renderer, '-Tcmapx', '-o', mapfile, '-T', target, dot_sourcepath, '-o', outputfile],
- shell=use_shell)
- else:
- subprocess.call([self.renderer, '-T', target,
- dot_sourcepath, '-o', outputfile],
- shell=use_shell)
+ try:
+ if mapfile:
+ subprocess.call([self.renderer, '-Tcmapx', '-o', mapfile, '-T', target, dot_sourcepath, '-o', outputfile],
+ shell=use_shell)
+ else:
+ subprocess.call([self.renderer, '-T', target,
+ dot_sourcepath, '-o', outputfile],
+ shell=use_shell)
+ except OSError as e:
+ if e.errno == errno.ENOENT:
+ e.strerror = 'File not found: {0}'.format(self.renderer)
+ raise
os.unlink(dot_sourcepath)
return outputfile