Esempio n. 1
0
 def fillDotFile(self, oobj, dotFile, request=None):
     """generate the dot file
     """
     print >> dotFile, '// GraphViz DOT-File'
     print >> dotFile, 'graph "map_%s" {' % (oobj.ikName)
     if request:
         mode = request.get('mode', default=None)
     if mode and mode.lower() == "fview":
         print >> dotFile, '\tgraph [bgcolor="#E5FFF9", dpi="100.0"];'
     else:
         print >> dotFile, '\tgraph [bgcolor="#E5FFF9", size="6.2,5.2",' +\
         ' splines="true", ratio = "auto", dpi="100.0"];'
     print >> dotFile, '\tnode [fontname = "Sans",fontsize = 10, URL="\N"];'
     print >> dotFile, '\tedge [style = "setlinewidth(2)", color = black];'
     print >> dotFile, '\trankdir = LR;'
     #for (dummy_name, oobj) in objList:
     #if ISupernode.providedBy(oobj):
     #try:
     adapterGenGraphvizDot = IGenGraphvizDot(oobj)
     if adapterGenGraphvizDot:
         #adapterGenGraphvizDot.setParent(oobj)
         adapterGenGraphvizDot.traverse4DotGenerator(\
             dotFile, 1, False, request)
         #except TypeError, err:
         #logger.error("TypeError in fillDotFile() [%s]" % err)
     print >> dotFile, '}'
     dotFile.flush()
Esempio n. 2
0
 def fillDotFile(self, oobj, dotFile, request=None):
     """generate the dot file
     """
     print >> dotFile, '// GraphViz DOT-File'
     print >> dotFile, 'graph "%s" {' % (oobj.ikName)
     print >> dotFile, '\tgraph [bgcolor="#E5FFF9"];'
     print >> dotFile, '\tedge [style = "setlinewidth(2)", color = gray];'
     print >> dotFile, '\trankdir = LR;'
     print >> dotFile, 'node [URL="\N"];'
     #for (dummy_name, oobj) in objList:
     #if ISupernode.providedBy(oobj):
     #try:
     adapterGenGraphvizDot = IGenGraphvizDot(oobj)
     if adapterGenGraphvizDot:
         #adapterGenGraphvizDot.setParent(oobj)
         adapterGenGraphvizDot.traverse4DotGenerator(\
             dotFile, 1, False, request)
         #except TypeError, err:
         #logger.error("TypeError in fillDotFile() [%s]" % err)
     print >> dotFile, '}'
     dotFile.flush()
Esempio n. 3
0
 def traverse4DotGeneratorBody(self,
                               cfgFile,
                               level=0,
                               comments=True,
                               request=None,
                               alreadySeenList=None):
     """graphviz configuration data of object
     """
     if comments:
         print >> cfgFile, "%s// Body (%s,%d) - RptDot" \
               % ("\t" * level, self.context, level)
     dot_str = '%s"%s" [' % ("\t" * level, self.context.objectID)
     dot_str += 'shape="diamond", '
     dot_str += 'label=<%s>,' % (self.context.ikName)
     dot_str += 'fontsize=10.0,'
     dot_str += 'fonttype="Sans"'
     if request:
         dot_str += ', \nURL="%s"' % zapi.absoluteURL(self.context, request)
     dot_str += '];'
     print >> cfgFile, dot_str
     if alreadySeenList == None:
         alreadySeenList = []
     alreadySeenList.append(self.context)
     itemNav = INavigation(self.context)
     tuplelist = itemNav.getContextObjList()
     for (attrName, viewTitle, contextObj) in tuplelist:
         if attrName is not None and viewTitle is not None:
             if type(attrName) is not type("str"):
                 raise TypeError("Nav_tuple_wrong: %s" % type(attrName))
             objList = getattr(contextObj, attrName)
             if objList.__class__ != list:
                 objList = [objList]
             for obj in objList:
                 if obj not in alreadySeenList:
                     try:
                         adapterGenGraphvizDot = IGenGraphvizDot(obj)
                     except TypeError:
                         adapterGenGraphvizDot = None
                     if adapterGenGraphvizDot:
                         adapterGenGraphvizDot.setParent(self.context)
                         adapterGenGraphvizDot.traverse4DotGenerator(\
                             cfgFile,
                             level+1,
                             comments,
                             request,
                             alreadySeenList)
     self.manageEvaluations(self.context, cfgFile, level, request)
     if self.parent != None:
         print >> cfgFile, '%s"%s" -- "%s";' \
               % ("\t" * level, self.parent.objectID, self.context.objectID)
Esempio n. 4
0
 def fillDotFile(self, objList, dotFile):
     """generate the dot file
     """
     print >> dotFile, '// GraphViz DOT-File'
     print >> dotFile, 'graph "%s" {' % (zapi.getRoot(self).__name__)
     print >> dotFile, '\tgraph [bgcolor="#E5FFF9"];'
     print >> dotFile, '\tedge [style = "setlinewidth(2)", color = gray];'
     print >> dotFile, '\trankdir = LR;'
     for (dummy_name, oobj) in objList:
         if ISupernode.providedBy(oobj):
             try:
                 adapterGenGraphvizDot = IGenGraphvizDot(oobj)
                 if adapterGenGraphvizDot:
                     adapterGenGraphvizDot.setParent(zapi.getRoot(self))
                     adapterGenGraphvizDot.traverse4DotGenerator(\
                         dotFile,
                         level=1,
                         comments=False)
             except TypeError, err:
                 logger.error("TypeError in fillDotFile() [%s]" % err)
Esempio n. 5
0
    def traverse4DotGeneratorBody(self, \
                                  cfgFile, \
                                  level=0, \
                                  comments=True,
                                  signalsOutput=False,
                                  recursive=True):
        """Pre-Text in graphviz dot-file"""
        if comments:
            print >> cfgFile, "%s// Body (%s,%d) - SupernodeGenGraphvizDot" \
                  % ("\t" * level, self.context.__name__, level)

        print >> cfgFile, '%s"%s" [' % ("\t" * level, self.context.objectID)
        print >> cfgFile, '%sshape="plaintext",' % ("\t" * (level + 1))
        print >> cfgFile, '%sstyle="filled,setlinewidth(0)",' \
              % ("\t" * (level + 1))
        print >> cfgFile, '%sfillcolor = chartreuse2,' % ("\t" * (level + 1))
        print >> cfgFile, '%smargin = 0,' % ("\t" * (level + 1))
        print >> cfgFile, '%shref = "%s/@@details.html",' \
              % ("\t" * (level + 1), zapi.getPath(self.context))

        #print >> cfgFile, '%slabel = <<TABLE BORDER = "0" CELLBORDER = "0" ' \
        #'CELLPADDING = "0" CELLSPACING = "0"><TR><TD>' \
        #'<IMG SRC = "/home/markus/Projekte/IKOMtrol-hp/apple-red.png"/>' \
        #'</TD></TR><TR><TD><FONT FACE = "Arial" POINT-SIZE = "10">%s' \
        #'</FONT></TD></TR></TABLE>>' \
        #% ("\t" * (level + 1), self.context.ikName)

        print >> cfgFile, '%slabel = <' % ("\t" * (level + 1))
        print >> cfgFile, '%s<TABLE BORDER="0" CELLBORDER="1" CELLPADDING = "2" CELLSPACING = "0">' % (
            "\t" * (level + 1))
        print >> cfgFile, '%s<TR><TD WIDTH="120px">%s</TD></TR>' % (
            "\t" * (level + 1), self.context.ikName)
        if signalsOutput:
            allInpNamesDict = self.context.getAllInpEventNames()
            for inpName in allInpNamesDict.keys():
                print >> cfgFile, '%s<TR><TD ALIGN="LEFT" PORT="%s" '\
                      'BGCOLOR="yellow">%s</TD></TR>' % \
                      ("\t" * (level + 1), inpName, inpName)
            allOutNamesDict = self.context.getAllOutEventNames()
            for outName in allOutNamesDict.keys():
                print >> cfgFile, '%s<TR><TD ALIGN="RIGHT" PORT="%s" '\
                      'BGCOLOR="orange">%s</TD></TR>' % \
                      ("\t" * (level + 1), outName, outName)
        #print >> cfgFile, '%s<TR><TD ALIGN="LEFT" PORT="sig_inp1" BGCOLOR="yellow">sig_inp1</TD></TR>' % ("\t" * (level + 1))
        #print >> cfgFile, '%s<TR><TD ALIGN="LEFT" PORT="sig_inp2" BGCOLOR="yellow">sig_inp2</TD></TR>' % ("\t" * (level + 1))
        #print >> cfgFile, '%s<TR><TD ALIGN="RIGHT" PORT="sig_out1" BGCOLOR="orange">sig_out1</TD></TR>' % ("\t" * (level + 1))
        print >> cfgFile, '%s</TABLE>>' % ("\t" * (level + 1))
        print >> cfgFile, '%s]; // %s' % ("\t" * level, self.context.__name__)
        if recursive:
            its = self.context.items()
        else:
            its = []
        for (dummy_name, oobj) in its:
            if ISuperclass.providedBy(oobj):
                try:
                    adapterGenGraphvizDot = IGenGraphvizDot(oobj)
                    if adapterGenGraphvizDot:
                        adapterGenGraphvizDot.setParent(self.context)
                        adapterGenGraphvizDot.traverse4DotGenerator(\
                            cfgFile, level + 1, comments, signalsOutput)
                except TypeError, err:
                    logging.error("Error in AdmUtilGraphviz::getRootDot()"\
                                  % err)
Esempio n. 6
0
    def fillDotFile(self, dotFile, mode=None):
        """generate the dot file
        """
        my_catalog = zapi.getUtility(ICatalog)
        objIdSet = set()
        objSet = set()
        eventSet = set()
        for (oid, oobj) in self.items():
            objIdSet.add(oid)
        for objId in self.inpEQueues:
            objIdSet.add(objId)
        for objId in self.outEQueues:
            objIdSet.add(objId)
        for objId in objIdSet:
            for result in my_catalog.searchResults(oid_index=objId):
                if IAdmUtilEvent.providedBy(result):
                    eventSet.add(result)
                elif IEventLogic.providedBy(result):
                    objSet.add(result)
                elif IEventLogic.providedBy(result):
                    objSet.add(result)
                elif IComponent.providedBy(result):
                    if result.isConnectedToEvent():
                        objSet.add(result)
                else:
                    pass
        print >> dotFile, '// GraphViz DOT-File'
        print >> dotFile, 'digraph "%s" {' % (zapi.getRoot(self).__name__)
        if mode and mode.lower() == "fview":
            print >> dotFile, '\tgraph [bgcolor="#E5FFF9", dpi="100.0"];'
        else:
            print >> dotFile, '\tgraph [bgcolor="#E5FFF9", size="6.2,5.2",' +\
            ' splines="true", ratio = "auto", dpi="100.0"];'
        print >> dotFile, '\tnode [fontname = "Helvetica",fontsize = 10];'
        print >> dotFile, '\tedge [style = "setlinewidth(2)", color = black];'
        print >> dotFile, '\trankdir = LR;'
        print >> dotFile, '\t// objects ----------------------------------'
        for obj in objSet:
            objGraphvizDot = IGenGraphvizDot(obj)
            objGraphvizDot.traverse4DotGenerator(dotFile,
                                                 level=1,
                                                 comments=True,
                                                 signalsOutput=True,
                                                 recursive=False)
        #print "-" * 80
        #uidutil = zapi.getUtility(IIntIds)
        #print >> dotFile, '\t// locations ----------------------------------'
        #for (oid, oobj) in uidutil.items():
        #if ILocation.providedBy(oobj.object):
        #print "Location: ", oobj.object.ikName
        #print >> dotFile, \
        #'\tsubgraph "cluster_location" { color=blue; label="location"};'
        ##elif IRoom.providedBy(oobj.object):
        ##print "Room: ", oobj.object.ikName
        ##elif ILocation.providedBy(oobj.object):
        ##print "Location: ", oobj.object.ikName
        #print "-" * 80

        print >> dotFile, '\t// events ----------------------------------'
        for event in eventSet:
            eventGraphvizDot = IGenGraphvizDot(event)
            eventGraphvizDot.traverse4DotGenerator(dotFile,
                                                   level=1,
                                                   comments=True)
        for obj in objSet:
            allInpNamesDict = obj.getAllInpEventNames()
            allOutNamesDict = obj.getAllOutEventNames()
            for inpName in allInpNamesDict.keys():
                for iObj in allInpNamesDict[inpName]:
                    print >> dotFile, '\t "%s"-> "%s":"%s"' % (
                        iObj, obj.objectID, inpName)
            for outName in allOutNamesDict.keys():
                for iObj in allOutNamesDict[outName]:
                    print >> dotFile, '\t "%s":"%s"-> "%s"' % (obj.objectID,
                                                               outName, iObj)
        print >> dotFile, '}'
        dotFile.flush()