[graph] More explicit error message if dot is not found/executable (closes #253516)

authorDavid Douard <david.douard@logilab.fr>
changesetdee2a57e9eb7
branchdefault
phasedraft
hiddenyes
parent revision#4085cf1c6908 [test] fix text_to_dict doctest (closes #174440)
child revision<not specified>
files modified by this revision
graph.py
# HG changeset patch
# User David Douard <david.douard@logilab.fr>
# Date 1409568136 -7200
# Mon Sep 01 12:42:16 2014 +0200
# Node ID dee2a57e9eb76c27dd59e09515e32bccbfbad002
# Parent 4085cf1c6908a87efd83c0b503fd8f3f3c0ef163
[graph] More explicit error message if dot is not found/executable (closes #253516)

diff --git a/graph.py b/graph.py
@@ -112,17 +112,22 @@
1          if target != 'dot':
2              if sys.platform == 'win32':
3                  use_shell = True
4              else:
5                  use_shell = False
6 -            if mapfile:
7 -                subprocess.call([self.renderer,  '-Tcmapx', '-o', mapfile, '-T', target, dot_sourcepath, '-o', outputfile],
8 -                                shell=use_shell)
9 -            else:
10 -                subprocess.call([self.renderer, '-T',  target,
11 -                                 dot_sourcepath, '-o',  outputfile],
12 -                                shell=use_shell)
13 +            try:
14 +                if mapfile:
15 +                    subprocess.call([self.renderer,  '-Tcmapx', '-o', mapfile, '-T', target, dot_sourcepath, '-o', outputfile],
16 +                                    shell=use_shell)
17 +                else:
18 +                    subprocess.call([self.renderer, '-T',  target,
19 +                                     dot_sourcepath, '-o',  outputfile],
20 +                                    shell=use_shell)
21 +            except OSError as e:
22 +                if e.errno == errno.ENOENT:
23 +                    e.strerror = 'File not found or not executable: {0}'.format(self.renderer)
24 +                    raise
25              os.unlink(dot_sourcepath)
26          return outputfile
27 
28      def emit(self, line):
29          """Adds <line> to final output."""