1 | #!/usr/bin/python |
---|
2 | |
---|
3 | import sys |
---|
4 | import pbs |
---|
5 | |
---|
6 | def test_init(): |
---|
7 | print 'Test init' |
---|
8 | |
---|
9 | w = pbs.new_attrl(2) |
---|
10 | print type(w) |
---|
11 | |
---|
12 | print 'end Test init' |
---|
13 | |
---|
14 | def test_getitem(): |
---|
15 | print 'Test getitem' |
---|
16 | |
---|
17 | w = pbs.new_attrl(2) |
---|
18 | b = w[0] |
---|
19 | c = w[1] |
---|
20 | |
---|
21 | print b, type(b) |
---|
22 | |
---|
23 | b.name = 'bas' |
---|
24 | b.value = 'vlies' |
---|
25 | print 'b', b |
---|
26 | |
---|
27 | c.name = 'cbassssssssssss' |
---|
28 | c.value = 'cvlies' |
---|
29 | print 'c', c |
---|
30 | |
---|
31 | def test_loop(): |
---|
32 | print 'Test loop' |
---|
33 | w = pbs.new_attrl(2) |
---|
34 | b = w[0] |
---|
35 | c = w[1] |
---|
36 | |
---|
37 | b.name = 'bas' |
---|
38 | b.value = 'vlies' |
---|
39 | c.name = 'jaap' |
---|
40 | c.value = 'dijkshoorn' |
---|
41 | |
---|
42 | for i in w: |
---|
43 | print i |
---|
44 | |
---|
45 | |
---|
46 | test_init() |
---|
47 | test_getitem() |
---|
48 | test_loop() |
---|
49 | |
---|
50 | pbs_server = pbs.pbs_default() |
---|
51 | con = pbs.pbs_connect(pbs_server) |
---|
52 | print con |
---|
53 | |
---|
54 | z = pbs.new_attrl(2) |
---|
55 | z[0].name = 'state' |
---|
56 | z[1].name = 'ntype' |
---|
57 | |
---|
58 | #z.append('bla'); |
---|
59 | #print 'z', z |
---|
60 | |
---|
61 | for entry in z: |
---|
62 | print 'entry', entry |
---|
63 | |
---|
64 | x = pbs.new_attrl(1) |
---|
65 | x[0].name = 'np' |
---|
66 | |
---|
67 | combine = z + x |
---|
68 | print combine, len(combine) |
---|
69 | |
---|
70 | #print combine[0].name |
---|
71 | #print combine[1].name |
---|
72 | #print combine[2].name |
---|
73 | |
---|
74 | nodes = pbs.pbs_statnode(con, "", 'NULL', "NULL") |
---|
75 | for node in nodes: |
---|
76 | print node.name, ':' |
---|
77 | for prop in node.attribs: |
---|
78 | print '\t', prop.name, ' = ', prop.value |
---|
79 | |
---|
80 | queues = pbs.pbs_statque(con, "", 'NULL', "") |
---|
81 | for queue in queues: |
---|
82 | print queue.name |
---|
83 | for attrib in queue.attribs: |
---|
84 | print '\t', attrib.name, ' = ', attrib.value |
---|
85 | |
---|
86 | jobs = pbs.pbs_statjob(con, "", 'NULL', "") |
---|
87 | for job in jobs: |
---|
88 | print job.name |
---|
89 | for attrib in job.attribs: |
---|
90 | print '\t', attrib.name, ' = ', attrib.value |
---|
91 | |
---|
92 | sys.exit(0) |
---|
93 | |
---|
94 | ## OLD stuff obselete |
---|
95 | ## |
---|
96 | while batch_info.this: |
---|
97 | node_attr = batch_info.attribs |
---|
98 | print batch_info.name, ':' |
---|
99 | while node_attr.this: |
---|
100 | # print node_attr.this |
---|
101 | print '\t', node_attr.name ,node_attr.value |
---|
102 | node_attr = node_attr.next |
---|
103 | |
---|
104 | batch_info = batch_info.next |
---|
105 | |
---|