Skip to content
Snippets Groups Projects
Commit 67433db1 authored by hagrid67's avatar hagrid67
Browse files

ignore absent pygraphviz - wrap render call (to_agraph) in try/except ImportError in agent_chains

parent 22fe14ba
No related branches found
No related tags found
No related merge requests found
...@@ -182,14 +182,19 @@ class MotionCheck(object): ...@@ -182,14 +182,19 @@ class MotionCheck(object):
def render(omc:MotionCheck, horizontal=True): def render(omc:MotionCheck, horizontal=True):
oAG = nx.drawing.nx_agraph.to_agraph(omc.G) try:
oAG.layout("dot") oAG = nx.drawing.nx_agraph.to_agraph(omc.G)
sDot = oAG.to_string() oAG.layout("dot")
if horizontal: sDot = oAG.to_string()
sDot = sDot.replace('{', '{ rankdir="LR" ') if horizontal:
#return oAG.draw(format="png") sDot = sDot.replace('{', '{ rankdir="LR" ')
# This returns a graphviz object which implements __repr_svg #return oAG.draw(format="png")
return gv.Source(sDot) # This returns a graphviz object which implements __repr_svg
return gv.Source(sDot)
except ImportError as oError:
print("Flatland agent_chains ignoring ImportError - install pygraphviz to render graphs")
return None
class ChainTestEnv(object): class ChainTestEnv(object):
""" Just for testing agent chains """ Just for testing agent chains
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment