|
From: Sebastian K. <seb...@gm...> - 2003-10-28 15:03:06
|
Hi openflowers,
OpenFlowEditor doesn't work on Win for some reasons:
1. Win is very particular in reading from binary files and showing the
binary data (result = out.read())
2. mktemp seem to work not relliably on Win (shows abreviated foldernames
(myFol~/anotherFo~/) at least on my machine)
3. The install_path of graphviz on Win machines is different to the
unix-standard
The following patch solves all this and works at least on my Win-box as
expected, when placed in a file Products/OpenFlow/EditorWinPatch/_init_.py
1. if Win it sets binary-data-reading and showing
2. it generates a temp_filename from DateTime()
3. it allows to configure the install path with the variable:
dot_install_path
I hope this helps other Win-users to enjoy this nice tool like I do,
SK
The patch for %InstanceHome/Products/OpenFlow/EditorWinPatch/_init_.py
############################################################################
##
#
# MonkeyPatch for OpenFlowEditor -> plotter.py
# Sebi: 29.10.03
#
# changed def runDot
#
############################################################################
##
# patching OpenFlowEditor.plotter.py
from Products import OpenFlowEditor
import os
import DateTime
def s_mktemp (ext) :
fileplace = os.path.join(CLIENT_HOME, 'wf_temp%s%s' %
(DateTime.DateTime().millis(), ext))
return fileplace
def runDot(input_list, format='gif') :
#new:start
import sys
if sys.platform == "win32":
import msvcrt
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
dot_install_path =
'C:\\yourLocal\\installPath\\toGraphviz\\bin\\dot.exe'
#new:end
infile = s_mktemp('.dot') # changed
f = open(infile, 'w')
f.write("%s" % OpenFlowEditor.plotter.parseInput(input_list))
f.close()
outfile = s_mktemp('.%s' % format) # changed
os.system('%s -T%s -o %s %s' % (dot_install_path, format, outfile,
infile)) # changed
out = open(outfile, 'rb')
result = out.read()
out.close()
os.remove(infile)
os.remove(outfile)
return result
# replace original method
OpenFlowEditor.plotter.runDot = runDot
|