Changeset 204 for trunk


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

Show how to use the new data structure.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/examples/new_interface.py

    r190 r204  
    1212
    1313from PBSQuery import PBSQuery
     14from PBSQuery import PBSError
     15
     16import sys
    1417
    1518def main():
     
    1821  p.new_data_structure()
    1922
    20   jobs = p.getjobs()
    21   for id in jobs:
    22      print id + ':'
    23      for attr in jobs[id]:
    24         print '\t' + attr, jobs[id][attr]
    25      
    26   l = ['state', 'np' ]
     23  #job = p.getjob('2983215')
     24  #print job['substate']
     25  #print job.substate
     26  #print job.queue
     27  #print job.Resource_List
     28  #print job.Resource_List.nodes
     29  #print job.Resource_List.arch
     30  #print job.Variable_List.PBS_O_HOME
     31
     32  l = ['np', 'status', 'state' ]
    2733  nodes = p.getnodes(l)
    2834  for id in nodes:
    29      print id + ': ', nodes[id].state, nodes[id].np
     35        print id
    3036
    31      for attrib in nodes[id]:
    32         print attrib, nodes[id][attrib]
     37        try:
     38                print nodes[id].np
     39                print nodes[id].status.arch
     40                print nodes[id].status.uname
     41                print nodes[id].state
     42        except PBSError, detail:
     43                print detail
     44                pass
     45       
     46     #for attrib in nodes[id]:
     47     #  print attrib, nodes[id][attrib]
    3348
    3449main()
Note: See TracChangeset for help on using the changeset viewer.