mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 14:25:26 +00:00
python: Allow ovs-flowviz to run without graphviz.
The graphviz library has a large set of dependencies, and as such it may be desireable to not install it by default. Before this patch execution of ovs-flowviz would end in ImportError when graphviz is unavailable. Exit with a friendly message instead, allowing the user to consume the parts of the program that do not depend on graphviz. Signed-off-by: Frode Nordahl <fnordahl@ubuntu.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
This commit is contained in:
committed by
Ilya Maximets
parent
e4193663af
commit
6a1a5f2eec
@@ -14,16 +14,26 @@
|
||||
|
||||
""" Defines a Datapath Graph using graphviz. """
|
||||
import colorsys
|
||||
import graphviz
|
||||
import random
|
||||
import sys
|
||||
|
||||
from ovs.flowviz.odp.html import HTMLTree, HTMLFormatter
|
||||
from ovs.flowviz.odp.tree import FlowTree
|
||||
from ovs.flowviz.process import FileProcessor
|
||||
|
||||
try:
|
||||
import graphviz
|
||||
except ImportError:
|
||||
graphviz = None
|
||||
|
||||
|
||||
class GraphProcessor(FileProcessor):
|
||||
def __init__(self, opts):
|
||||
if graphviz is None:
|
||||
print("ERROR: The graph sub-command depends on the graphviz "
|
||||
"Python library, which does not appear to be installed.",
|
||||
file=sys.stderr)
|
||||
sys.exit(1)
|
||||
super().__init__(opts, "odp")
|
||||
|
||||
def start_file(self, name, filename):
|
||||
|
Reference in New Issue
Block a user