Changeset 73


Ignore:
Timestamp:
04/15/05 11:43:04 (19 years ago)
Author:
bastiaans
Message:

daemon/togad.py:

  • Added check if info changed on a job
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/daemon/togad.py

    r72 r73  
    171171               
    172172                heartbeat = 0
     173               
     174                jobinfo = { }
    173175
    174176                if name == 'METRIC':
     
    184186                                val = attrs.get( 'VAL', "" )
    185187
     188                                check_change = 0
     189
     190                                if self.jobAttrs.has_key( job_id ):
     191                                        check_change = 1
     192
     193                                if not jobinfo.has_key( job_id ):
     194                                        jobinfo[ job_id ] = { }
     195
    186196                                valinfo = val.split( ' ' )
    187                                 print valinfo
    188197
    189198                                for myval in valinfo:
     
    195204                                                value = value.split( ';' )
    196205
    197                                         if not self.jobAttrs.has_key( job_id ):
    198                                                 self.jobAttrs[ job_id ] = { }
    199 
    200                                         self.jobAttrs[ job_id ][ valname ] = value
    201 
    202                 print self.jobAttrs
     206                                        jobinfo[ job_id ][ valname ] = value
     207
     208                                if check_change:
     209                                        if self.jobinfoChanged( self.jobAttrs, job_id, jobinfo ):
     210                                                self.jobAttrs[ job_id ] = jobinfo
     211                                                debug_msg( 0, 'jobinfo for job %s has changed' %job_id )
     212                                else:
     213                                        self.jobAttrs[ job_id ] = jobinfo
     214                                        debug_msg( 0, 'jobinfo for job %s has changed' %job_id )
     215                                       
     216
     217        def jobinfoChanged( self, jobattrs, jobid, jobinfo ):
     218
     219                if jobattrs.has_key( jobid ):
     220
     221                        for valname, value in jobinfo.items():
     222
     223                                if jobattrs[ jobid ].has_key( valname ):
     224
     225                                        if value != jobattrs[ jobid ][ valname ]:
     226
     227                                                return 1
     228
     229                                else:
     230                                        return 1
     231
     232                return 0
    203233
    204234class GangliaXMLHandler( xml.sax.handler.ContentHandler ):
     
    413443                self.myXMLGatherer = GangliaXMLGatherer( ARCHIVE_XMLSOURCE.split( ':' )[0], ARCHIVE_XMLSOURCE.split( ':' )[1] )
    414444                self.myXMLSource = self.myXMLGatherer.getFileObject()
     445                self.myTXHandler = TorqueXMLHandler()
     446                self.myXMLerror = XMLErrorHandler()
     447
    415448                while( 1 ):
     449
    416450                        print 'parse'
    417451                        self.myXMLGatherer.makeFileDescriptor()
    418452                        self.myXMLSource = self.myXMLGatherer.getFileObject()
    419                         xml.sax.parse( self.myXMLSource, TorqueXMLHandler(), XMLErrorHandler() )
     453                        xml.sax.parse( self.myXMLSource, self.myTXHandler, self.myXMLerror )
     454                        print self.myTXHandler.jobAttrs
    420455                        print 'sleep'
    421456                        time.sleep( 1 )
     457
     458                #self.myGXHandler = GangliaXMLHandler( self.config )
    422459                #self.myHandler = GangliaXMLHandler( self.config )
    423460                #self.myHandler = TorqueXMLHandler( )
Note: See TracChangeset for help on using the changeset viewer.