Changeset 171


Ignore:
Timestamp:
10/10/08 10:45:35 (16 years ago)
Author:
sil
Message:

trunk/src/PBSQuery.py:

  • Added a function 'uniq' to class _PBSobject, to be able to filter out unique items in a list of nodes/jobs/...
  • Added a function in the job-class to get a list of nodes it's running on
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/CHANGES

    r169 r171  
    3838                * Added to class node the function
    3939                 - get_jobs(self, unique=None)
    40                    Returns a list of the currently running job-id('s) on the node.
    41                
    42                   Added by: Sil Westerveld <Sil.Westerveld@sara.nl>
     40                   Returns a list of the currently running job-id('s) on the node.
     41                Added by: Sil Westerveld <Sil.Westerveld@sara.nl>
    4342
    4443                * Added get_server_name() function.
    4544                  This will return the PBS-server's name.
    46 
    47                   Added by: Sil Westerveld <Sil.Westerveld@sara.nl>
     45                Added by: Sil Westerveld <Sil.Westerveld@sara.nl>
     46
     47                * Added to class _PBSobject the function
     48                  - uniq(self, list)
     49                    Filters out unique items of a list.
     50                Added by: Sil Westerveld <Sil.Westerveld@sara.nl>
     51
     52                * Added to class job the function
     53                  - get_nodes(self, unique=None)
     54                    Returns a list of the nodes which run the job.
     55                Added by: Sil Westerveld <Sil.Westerveld@sara.nl>
    4856
    4957=========== Version 2.9.4
  • trunk/src/PBSQuery.py

    r169 r171  
    238238                        return None
    239239
     240        def uniq(self, list):
     241                """Filter out unique items of a list"""
     242                uniq_items = {}
     243                for item in list:
     244                        uniq_items[item] = 1
     245                return uniq_items.keys()
     246
    240247class job(_PBSobject):
    241248        """PBS job class"""
     
    246253                        return self.TRUE
    247254
    248         def get_nodes(self):
     255        def get_nodes(self, unique=None):
     256                """Returns a list of the nodes which run this job"""
    249257                nodes = self.get_value('exec_host')
    250258                if nodes:
    251                         l = string.split(nodes,'+')
    252                         return l
     259                        nodelist = string.split(nodes,'+')
     260                        if not unique:
     261                                return nodelist
     262                        else:
     263                                return self.uniq(nodelist)
    253264                return list()
    254265
     
    279290                                return joblist
    280291                        else:
    281                                 uniq = {}
    282                                 for job in joblist:
    283                                         uniq[job] = 1
    284                                 return uniq.keys()
     292                                return self.uniq(joblist)
    285293                return list()
    286294
Note: See TracChangeset for help on using the changeset viewer.