Changeset 525 for trunk


Ignore:
Timestamp:
03/19/08 10:48:11 (16 years ago)
Author:
bastiaans
Message:

jobmond/jobmond.py:

  • changed countDuplicateList: previous function gives a error in python2.3
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/jobmond/jobmond.py

    r524 r525  
    10581058#
    10591059class LsfDataGatherer(DataGatherer):
     1060
    10601061        """This is the DataGatherer for LSf"""
    10611062
     
    10631064
    10641065        def __init__( self ):
     1066
    10651067                self.jobs = { }
    10661068                self.timeoffset = 0
     
    10681070                self.initLsfQuery()
    10691071
    1070 ########################
    1071 ## THIS IS TAKEN FROM
    1072 ## http://bigbadcode.com/2007/04/04/count-the-duplicates-in-a-python-list/
    1073         from sets import Set
    1074 #
    1075         def _countDuplicatesInList(self,dupedList):
    1076                 uniqueSet = self.Set(item for item in dupedList)
    1077                 return [(item, dupedList.count(item)) for item in uniqueSet]
     1072        def _countDuplicatesInList( self, dupedList ):
     1073
     1074                countDupes      = { }
     1075
     1076                for item in dupedList:
     1077
     1078                        if not countDupes.has_key( item ):
     1079
     1080                                countDupes[ item ]      = 1
     1081                        else:
     1082                                countDupes[ item ]      = countDupes[ item ] + 1
     1083
     1084                dupeCountList   = [ ]
     1085
     1086                for item, count in countDupes.items():
     1087
     1088                        dupeCountList.append( ( item, count ) )
     1089
     1090                return dupeCountList
    10781091#
    10791092#lst = ['I1','I2','I1','I3','I4','I4','I7','I7','I7','I7','I7']
     
    10851098                self.pq = None
    10861099                self.pq = lsfObject.jobInfoEntObject()
    1087 
    1088         def getAttr( self, attrs, name ):
    1089                 """Return certain attribute from dictionary, if exists"""
    1090                 if attrs.has_key( name ):
    1091                         return attrs[name]
    1092                 else:
    1093                         return ''
    10941100
    10951101        def getJobData( self, known_jobs="" ):
     
    12041210                                jobs[ job_id ] = myAttrs
    12051211
    1206                                 #debug_msg( 10, printTime() + ' job %s state changed' %(job_id) )
     1212                                debug_msg( 10, printTime() + ' job %s state changed' %(job_id) )
    12071213
    12081214                for id, attrs in jobs.items():
    12091215                        if id not in jobs_processed:
    1210                                 # This one isn't there anymore; toedeledoki!
     1216                                # This one isn't there anymore
    12111217                                #
    12121218                                del jobs[ id ]
Note: See TracChangeset for help on using the changeset viewer.