@@ -1019,20 +1019,22 @@ def export_graph(graph_in, base_dir=None, show=False, use_execgraph=False,
10191019 use_ext = False ,
10201020 newpath = base_dir )
10211021 _write_detailed_dot (graph , outfname )
1022- cmd = 'dot -T%s -O %s' % (format , outfname )
1023- res = CommandLine (cmd , terminal_output = 'allatonce' ).run ()
1024- if res .runtime .returncode :
1025- logger .warn ('dot2png: %s' , res .runtime .stderr )
1022+ if format != 'dot' :
1023+ cmd = 'dot -T%s -O %s' % (format , outfname )
1024+ res = CommandLine (cmd , terminal_output = 'allatonce' ).run ()
1025+ if res .runtime .returncode :
1026+ logger .warn ('dot2png: %s' , res .runtime .stderr )
10261027 pklgraph = _create_dot_graph (graph , show_connectinfo , simple_form )
10271028 simplefname = fname_presuffix (dotfilename ,
10281029 suffix = '.dot' ,
10291030 use_ext = False ,
10301031 newpath = base_dir )
10311032 nx .drawing .nx_pydot .write_dot (pklgraph , simplefname )
1032- cmd = 'dot -T%s -O %s' % (format , simplefname )
1033- res = CommandLine (cmd , terminal_output = 'allatonce' ).run ()
1034- if res .runtime .returncode :
1035- logger .warn ('dot2png: %s' , res .runtime .stderr )
1033+ if format != 'dot' :
1034+ cmd = 'dot -T%s -O %s' % (format , simplefname )
1035+ res = CommandLine (cmd , terminal_output = 'allatonce' ).run ()
1036+ if res .runtime .returncode :
1037+ logger .warn ('dot2png: %s' , res .runtime .stderr )
10361038 if show :
10371039 pos = nx .graphviz_layout (pklgraph , prog = 'dot' )
10381040 nx .draw (pklgraph , pos )
@@ -1045,18 +1047,17 @@ def export_graph(graph_in, base_dir=None, show=False, use_execgraph=False,
10451047 return simplefname if simple_form else outfname
10461048
10471049
1048- def format_dot (dotfilename , format = None ):
1050+ def format_dot (dotfilename , format = 'png' ):
10491051 """Dump a directed graph (Linux only; install via `brew` on OSX)"""
1050- cmd = 'dot -T%s -O \' %s\' ' % (format , dotfilename )
1051- try :
1052- CommandLine (cmd ).run ()
1053- except IOError as ioe :
1054- if "could not be found" in str (ioe ):
1055- raise IOError ("Cannot draw directed graph; executable 'dot' is unavailable" )
1056- else :
1057- raise ioe
1058-
10591052 if format != 'dot' :
1053+ cmd = 'dot -T%s -O \' %s\' ' % (format , dotfilename )
1054+ try :
1055+ CommandLine (cmd ).run ()
1056+ except IOError as ioe :
1057+ if "could not be found" in str (ioe ):
1058+ raise IOError ("Cannot draw directed graph; executable 'dot' is unavailable" )
1059+ else :
1060+ raise ioe
10601061 dotfilename += '.%s' % format
10611062 return dotfilename
10621063
0 commit comments