Changeset 205 for trunk


Ignore:
Timestamp:
11/12/09 15:43:13 (14 years ago)
Author:
bas
Message:

Preparing for new version 3.5

src/PBSQuery.py:

  • rewrite of dictionary code
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/AUTHORS

    r181 r205  
    66
    77PBSQuery module:
    8         Roy Dragseth
    98        Bas van der Vlies
    109
     
    1413        Dennis Stam
    1514        Sil Westerveld
     15        Roy Dragseth
  • trunk/CHANGES

    r196 r205  
    1 =========== 3.2.5
    2         - PBSQuery
    3           The class function of node, job and queue support old and new data structure.
    4         Author: Bas van der Vlies
     1=========== 3.5.0
     2  * PBSQuery
     3        The class functions of node, job and queue support old and new data
     4        structure.
     5
     6        Changed the behaviour of the new data stucture, We can use it as
     7        dictionary and as class attribute, this is equivalent, eg:
     8          - print node['np'] and print node.np
     9
     10        for a node we parse the 'status' line and split on '=' char, You now can
     11        use these statements, eg
     12          - print node.status.arch     (node['status'].arch or node['status']['arch'])
     13          - print node.status.nsession
     14
     15        for a job we parse the 'Variable_List' line and split on '=' char, You now can
     16        use the statements, eg:
     17          - print job.Variable_List.PBS_O_WORKDIR
     18          - print job.Variable_List.PBS_O_HOME
     19
     20        For more info see examples/new_interface.py
     21
     22    Author: Bas van der Vlies
     23
     24 * new_rack_pbsmon.py
     25        Rewrite to new data structure and automatically determine how many nodes
     26        and racks cluster has and skip printing of empty racks (default), use -w/--wide
     27        for old behaviour.
     28
     29   Author: Bas van der Vlies
     30
    531
    632=========== 3.2.0
  • trunk/debian/changelog

    r203 r205  
    1 pbs-python (3.2.5-2) intrepid; urgency=low
     1pbs-python (3.5.0-1) lenny; urgency=low
    22
    33  * PBSQuery
    4         The class function of node, job and queue support old and new data
     4        The class functions of node, job and queue support old and new data
    55        structure.
     6
     7        Changed the behaviour of the new data stucture, We can use it as
     8        dictionary and as class attribute, this is equivalent, eg:
     9          - print node['np'] and print node.np
     10
     11        for a node we parse the 'status' line and split on '=' char, You now can
     12        use these statements, eg
     13          - print node.status.arch     (node['status'].arch or node['status']['arch'])
     14          - print node.status.nsession
     15
     16        for a job we parse the 'Variable_List' line and split on '=' char, You now can
     17        use the statements, eg:
     18          - print job.Variable_List.PBS_O_WORKDIR
     19          - print job.Variable_List.PBS_O_HOME
     20
     21        For more info see examples/new_interface.py
     22
    623    Author: Bas van der Vlies
    724
     
    1330   Author: Bas van der Vlies
    1431
    15  -- Bas van der Vlies <bas@rc.sara.nl>  Mon, 18 May 2009 17:03:16 +0200
     32 -- Bas van der Vlies <bas@rc.sara.nl>  Mon, 12 Nov 2009 15:03:16 +0200
    1633
    1734pbs-python (3.2.0-1) intrepid; urgency=low
  • trunk/src/PBSQuery.py

    r195 r205  
    131131                             values contain a '=' character
    132132
    133                           eg:
     133                  eg:
    134134                            print node['np']
    135135                                >> [ '2' ]
     
    144144                        self.d[item.name] = new
    145145                       
    146                         new.name = item.name 
     146                        new.name = item.name
    147147
    148148                        for a in item.attribs:
    149149
    150                                 if a.resource:
    151                                         key = '%s.%s' %(a.name, a.resource)
    152                                 else:
    153                                         key = a.name
    154 
    155150                                if self.OLD_DATA_STRUCTURE:
     151
     152                                        if a.resource:
     153                                                key = '%s.%s' %(a.name, a.resource)
     154                                        else:
     155                                                key = '%s' %(a.name)
     156
    156157                                        new[key] = a.value
     158
    157159                                else:
    158160                                        values = string.split(a.value, ',')
    159                                        
    160                                         if len(values) == 1:
    161                                                 # simple form
    162                                                 # print 'simple %s =  %s' %(key, values[0])
     161                                        sub_dict = string.split(a.value, '=')
     162
     163
     164                                        if len(sub_dict) > 1:
     165                                                # We must creat sub dict, only for specified
     166                                                # key values
    163167                                                #
    164                                                 new[key] = values
    165 
    166                                         else:
    167                                                 # list check
    168                                                 list_or_dict = string.split(a.value, '=')
    169 
    170 
    171                                                 if len(list_or_dict) == 1:
    172                                                         # This is a list
    173                                                         # print 'list %s = %s' %(key, values)
     168                                                if a.name in ['status', 'Variable_List']:
     169
     170                                                        for v in values:
     171
     172                                                                tmp_l = v.split('=')
     173
     174                                                                # Check if we already added the key
     175                                                                #
     176                                                                if new.has_key(a.name):
     177                                                                        new[a.name][ tmp_l[0] ] = tmp_l[1:]
     178
     179                                                                else:
     180                                                                        tmp_d  = dict()
     181                                                                        tmp_d[ tmp_l[0] ] = tmp_l[1:]
     182                                                                        new[a.name] = class_func(tmp_d)
     183
     184                                        else:
     185                                                # Check if it is a resource type variable, eg:
     186                                                #  - Resource_List.(nodes, walltime, ..)
     187                                                #
     188                                                if a.resource:
     189
     190                                                        if new.has_key(a.name):
     191                                                                new[a.name][a.resource] = values
     192
     193                                                        else:
     194                                                                tmp_d = dict()
     195                                                                tmp_d[a.resource] = values
     196                                                                new[a.name] = class_func(tmp_d)
     197                                                else:
     198                                                        # Simple value
    174199                                                        #
    175                                                         new[key] = values
    176 
    177                                                 else:
    178                                                         # This is dictionary
    179                                                         # print 'dict %s = %s' %(key, values)
    180                                                         #
    181                                                         new[key] = dict()
    182                                                         for v in values:
    183                                                                 # First argument is the key and the rest is the value
    184                                                                 # - value can contain a '='
    185                                                                 #
    186                                                                 tmp = v.split('=')
    187                                                                 new[key][ tmp[0] ] =  tmp[1:]
    188                                                
     200                                                        new[a.name] = values
     201
    189202                self._free(l)
    190203               
     
    309322        FALSE = 0
    310323
    311         def __init__(self):
     324        def __init__(self, dictin = None):
    312325                UserDict.UserDict.__init__(self)
    313326                self.name = None
     327
     328                if dictin:
     329                        if dictin.has_key('name'):
     330                                self.name = dictin['name']
     331                                del dictin['name']
     332                        self.data = dictin
    314333
    315334        def get_value(self, key):
     
    329348                        return self.data[name]
    330349                except KeyError:
    331                         error = 'invalid attribute %s' %(name)
     350                        error = 'Attribute key error: %s' %(name)
    332351                        raise PBSError(error)
    333352
  • trunk/src/pbs.py

    r197 r205  
    534534  Returns the pbs python interface version as a string.
    535535  """
    536   return '3.2.5'
     536  return '3.5.0'
    537537
    538538# A useful dict with error codes to text
Note: See TracChangeset for help on using the changeset viewer.