15 __version__ =
"$Revision: 1.2 $"
16 __author__ =
"Ilija Vukotic <ivukotic@cern.ch>"
31 lRemove+= [
"MboyMuonChamberT0"]
32 lRemove+= [
'Stream',
'StreamAOD',
'noKey',
"basic_"]
33 lRemove+= [
"Trig",
"HLT",
"EF",
"L1",
"Mon",
"CTP",
"RoIB",
"GlobalManager"]
39 result=result.replace(
'>',
'_GT_')
40 result=result.replace(
'<',
'_LT_')
41 result=result.replace(
'::',
'_')
42 result=result.replace(
'.',
'_')
43 result=result.replace(
'+',
'_')
51 stripped =
str(
int(inpVal))
61 print "remove ", inpVal,
"is a number"
64 if inpVal.count(thing)>0:
66 print "remove ", inpVal ,
"since it contains", thing
74 print "Usage: SGout2dot.py input_filename [output dot file]"
77 print "Input file",sys.argv[1]
80 print "Output file",sys.argv[2]
88 fo = open (outFN,
'w' )
90 lines = fi.readlines()
97 print '%(a)d algorithms found'%{
'a':nAlgs}
103 for i
in range(nAlgs):
104 line=lines.pop(0).strip(
'\n')
105 line=line.replace(
'/',
'_')
108 print "alg %s to be removed" % line
112 print " number of good algs ",nGoodAlgs,
" bad algs ",nAlgs-nGoodAlgs
118 words=line.split(
' ')
120 print '%(a)d objects found'%{
'a':nObjs}
126 for i
in range(nObjs):
127 line=lines.pop(0).strip(
'\n')
128 line=line.replace(
'/',
'_')
129 line=line.replace(
'<',
'LT')
130 line=line.replace(
'>',
'GT')
131 line=line.replace(
'+',
'_')
134 print "obj %s to be removed" % line
138 print " number of good objs ",nGoodObjs,
" bad objs ",nObjs-nGoodObjs
142 fo.write(
"// %s algorithms and %s objects \n" % (nGoodAlgs,nGoodObjs))
146 fo.write(
"digraph SGAudSvc{\nrankdir=LR;\n")
147 fo.write(
"ratio=0.7;\nnodesep=0.05;\n")
148 fo.write(
"subgraph c_0{\nnode[style=filled,color=red];\n")
149 fo.write(
"label=\"Algs READING\";\ncolor=red;\n")
159 words=line.strip(
'\n').
split(
'\t')
164 if reads==0
and writes==0:
170 if writes==0
and reads>0:
171 if not obj
in algsReadingObj.keys():
172 algsReadingObj[obj]=[]
173 algsReadingObj[obj]+=[(alg,reads,writes)]
174 if not alg
in objsReadByAlg.keys():
175 objsReadByAlg[alg]=[]
176 objsReadByAlg[alg]+=[obj]
178 if not obj
in algsWritingObj.keys():
179 algsWritingObj[obj]=[]
180 algsWritingObj[obj]+=[alg]
182 if not alg
in objsWrittenByAlg.keys():
183 objsWrittenByAlg[alg]=[]
184 objsWrittenByAlg[alg]+=[(obj,reads,writes)]
190 if alg
in objsWrittenByAlg
or alg
in objsReadByAlg:
191 towrite=
'a_%(a)s [label=\"%(a)s\"];\n'%{
'a':
chLabel(alg),
'b':alg}
194 print "alg %s masked because not connected" % alg
196 fo.write(
"}\n\nsubgraph c_1{\nnode[style=filled,shape=box];\ncolor=green;label=\"Objects\";\n")
200 if obj
in algsWritingObj
or obj
in algsReadingObj:
201 towrite=
'o_%(a)s [label=\"%(b)s\"];\n'%{
'a':
chLabel(obj),
'b':obj}
204 print "obj %s masked because not connected" % obj
210 print "objsWrittenByAlg:", objsWrittenByAlg
212 print "objsReadByAlg:", objsReadByAlg
214 print "algsWritingObj:", algsWritingObj
216 print "algsReadingObj:", algsReadingObj
220 for alg
in objsWrittenByAlg.keys():
221 for objrec
in objsWrittenByAlg[alg]:
225 towrite=
'a_%(ALG)s -> o_%(OBJ)s [ '%{
'ALG':
chLabel(alg),
'OBJ':
chLabel(obj)}
228 towrite+=
'label=\"%s\" ' % writes
232 towrite+=
'label=\"w:%(WRITES)s r:%(READS)s\" arrowtail=\"normal\" '%{
'WRITES':writes,
'READS':reads}
235 towrite+=
'arrowtail=\"normal\" '
241 for obj
in algsReadingObj.keys():
242 for algrec
in algsReadingObj[obj]:
247 towrite=
'o_%(OBJ)s -> a_%(ALG)s [ '%{
'ALG':
chLabel(alg),
'OBJ':
chLabel(obj)}
249 towrite+=
'label=\"%s\" ' % reads