summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmile Anclin <devnull@localhost>2015-12-08 12:25:14 +0200
committerEmile Anclin <devnull@localhost>2015-12-08 12:25:14 +0200
commitcb41aa237e4c637da2a9be4e44823d036e1e6430 (patch)
tree6ce3299a2e6d7d7ff3d74e48c26fd6d492dc1680
parent3ca41ff239dc11404af65ca4a3060b92d87668ba (diff)
downloadpylint-cb41aa237e4c637da2a9be4e44823d036e1e6430.tar.gz
Give a nice error message when Graphviz is not installed. Closes issue #168.
-rw-r--r--ChangeLog3
-rw-r--r--pylint/pyreverse/main.py17
2 files changed, 20 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index f8129cc..052569f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,6 +13,9 @@ ChangeLog for Pylint
This prevents a crash which can occur when an object doesn't have
.qname() method after the inference.
+ * Don't crash if graphviz is not installed, instead emit a
+ warning letting the user to know.
+
* Don't emit super-on-old-class on classes with unknown bases.
Closes issue #721.
diff --git a/pylint/pyreverse/main.py b/pylint/pyreverse/main.py
index 0e7f87e..e56c9dd 100644
--- a/pylint/pyreverse/main.py
+++ b/pylint/pyreverse/main.py
@@ -21,6 +21,7 @@
from __future__ import print_function
import os
+import subprocess
import sys
from pylint.config import ConfigurationMixIn
@@ -91,6 +92,19 @@ this disables -f values")),
#( ('quiet',
#dict(help='run quietly', action='store_true', short='q')), )
+def _check_graphviz_available(output_format):
+ """check if we need graphviz for different output format"""
+ try:
+ subprocess.call(['dot', '-V'], stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ except OSError:
+ print("The output format '%s' is currently not available.\n"
+ "Please install 'Graphviz' to have other output formats "
+ "than 'dot' or 'vcg'." % output_format)
+ sys.exit(32)
+
+
+
class Run(ConfigurationMixIn):
"""base class providing common behaviour for pyreverse commands"""
@@ -100,6 +114,9 @@ class Run(ConfigurationMixIn):
ConfigurationMixIn.__init__(self, usage=__doc__)
insert_default_options()
args = self.load_command_line_configuration()
+ if self.config.output_format not in ('dot', 'vcg'):
+ _check_graphviz_available(self.config.output_format)
+
sys.exit(self.run(args))
def run(self, args):