Changeset 355 for trunk/jobmond


Ignore:
Timestamp:
05/03/07 15:09:25 (17 years ago)
Author:
bastiaans
Message:

jobmond/jobmond.py:

  • close gmetric pipe after checking version
  • more code cleanup
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/jobmond/jobmond.py

    r354 r355  
    200200
    201201class DataProcessor:
     202
    202203        """Class for processing of data"""
    203204
     
    205206
    206207        def __init__( self, binary=None ):
     208
    207209                """Remember alternate binary location if supplied"""
    208210
     
    234236
    235237                        if incompatible:
    236                                 debug_msg( 0, 'Gmetric version not compatible, pls upgrade to at least 3.0.1' )
     238
     239                                debug_msg( 0, 'Gmetric version not compatible, please upgrade to at least 3.0.1' )
    237240                                sys.exit( 1 )
    238241
    239242        def checkGmetricVersion( self ):
     243
    240244                """
    241245                Check version of gmetric is at least 3.0.1
     
    247251                incompatible    = 0
    248252
    249                 for line in os.popen( self.binary + ' --version' ).readlines():
     253                gfp             = os.popen( self.binary + ' --version' )
     254                lines           = gfp.readlines()
     255
     256                gfp.close()
     257
     258                for line in lines:
    250259
    251260                        line = line.split( ' ' )
    252261
    253                         if len( line ) == 2 and str(line).find( 'gmetric' ) != -1:
     262                        if len( line ) == 2 and str( line ).find( 'gmetric' ) != -1:
    254263                       
    255                                 gmetric_version = line[1].split( '\n' )[0]
    256 
    257                                 version_major = int( gmetric_version.split( '.' )[0] )
    258                                 version_minor = int( gmetric_version.split( '.' )[1] )
    259                                 version_patch = int( gmetric_version.split( '.' )[2] )
    260 
    261                                 incompatible = 0
     264                                gmetric_version = line[1].split( '\n' )[0]
     265
     266                                version_major   = int( gmetric_version.split( '.' )[0] )
     267                                version_minor   = int( gmetric_version.split( '.' )[1] )
     268                                version_patch   = int( gmetric_version.split( '.' )[2] )
     269
     270                                incompatible    = 0
    262271
    263272                                if version_major < 3:
     
    284293
    285294        def multicastGmetric( self, metricname, metricval, valtype='string' ):
     295
    286296                """Call gmetric binary and multicast"""
    287297
     
    324334
    325335        def printJobs( self, jobs ):
     336
    326337                """Print a jobinfo overview"""
    327338
     
    335346
    336347        def printJob( self, jobs, job_id ):
     348
    337349                """Print job with job_id from jobs"""
    338350
     
    344356
    345357        def daemon( self ):
     358
    346359                """Run as daemon forever"""
    347360
     
    380393
    381394        def run( self ):
     395
    382396                """Main thread"""
    383397
     
    507521                        self.dp.multicastGmetric( 'MONARCH-JOB-' + jobid + '-' + str(metric_increment), jobattrs)
    508522
    509 class PbsDataGatherer(DataGatherer):
     523class PbsDataGatherer( DataGatherer ):
    510524
    511525        """This is the DataGatherer for PBS and Torque"""
Note: See TracChangeset for help on using the changeset viewer.