Changeset 246 for trunk


Ignore:
Timestamp:
08/13/10 15:46:12 (14 years ago)
Author:
bas
Message:

get_nodes for job now works for new and old structure and fixed the unique output

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/CHANGES

    r245 r246  
    1212   Author: Mark Roberts ( mark at gingergeeks dot co dot uk)
    1313   Applied by: Bas van der Vlies
     14
     15 * get_nodes function for jobs now works for old and new datastructure and
     16   gives correct results if unique=True
     17   Author: Bas van der Vlies
    1418
    1519=========== 4.1.2
  • trunk/src/PBSQuery.py

    r245 r246  
    401401
    402402        def get_nodes(self, unique=None):
    403                 """Returns a list of the nodes which run this job"""
     403                """
     404                Returns a list of the nodes which run this job
     405                format:
     406                  * exec_host: gb-r10n14/5+gb-r10n14/4+gb-r10n14/3+gb-r10n14/2+gb-r10n14/1+gb-r10n14/0
     407                  * split on '+' and if uniq is set split on '/'
     408                """
    404409                nodes = self.get_value('exec_host')
    405                 if nodes:
    406                         nodelist = string.split(nodes,'+')
    407                         if not unique:
    408                                 return nodelist
     410               
     411                if isinstance(nodes, str):
     412                        if nodes:
     413                                nodelist = string.split(nodes,'+')
     414                                if not unique:
     415                                        return nodelist
     416                                else:
     417                                        l = list()
     418
     419                                        for n in nodelist:
     420                                                t = string.split(n,'/')
     421                                                if t[0] not in l:
     422                                                        l.append(t[0])
     423
     424                                        return l
     425
    409426                        else:
    410                                 return self.uniq(nodelist)
    411                 return list()
    412 
     427                                return list()
     428                else:
     429                                l = list()
     430                                for n in nodes:
     431
     432                                        nlist = string.split(n,'+')
     433
     434                                        if unique:
     435                                                for entry in nlist:
     436
     437                                                        t = string.split(entry,'/')
     438                                                        if t[0] not in l:
     439                                                                l.append(t[0])
     440                                        else:
     441                                                l += nlist
     442
     443                                return l
     444               
    413445
    414446class node(_PBSobject):
Note: See TracChangeset for help on using the changeset viewer.