File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change
1
+ from pythonlsf import lsf
2
+ import inspect
3
+
4
+ if __name__ == '__main__' :
5
+ if lsf .lsb_init ("test" ) > 0 :
6
+ exit - 1 ;
7
+
8
+ for hostInfoEnt in lsf .get_host_info_all ():
9
+ attributes = [d for d in dir (hostInfoEnt )
10
+ if not d .startswith ('__' )]
11
+ item = {}
12
+ for a in attributes :
13
+ v = getattr (hostInfoEnt , a )
14
+ if not inspect .ismethod (v ) and isinstance (v , (int , str , float )):
15
+ item [a ] = v
16
+ print (item )
Original file line number Diff line number Diff line change @@ -710,6 +710,25 @@ PyObject * get_pids_from_stream(struct jRusage * jrusage) {
710
710
PyList_SetItem (result, i, o);
711
711
}
712
712
return result;
713
- }
713
+ }
714
+
715
+ PyObject * get_host_info_all () {
716
+ struct hostInfoEnt *hostinfo;
717
+ char **hosts = NULL ;
718
+ int numhosts = 0 ;
719
+
720
+ // Return queries as C hostInfoEnt*
721
+ hostinfo = lsb_hostinfo (hosts, &numhosts);
722
+
723
+ PyObject *result = PyList_New (numhosts); // Create PyObject * to get C returns
724
+ int i;
725
+ for (i = 0 ; i < numhosts; i++) { // Save queries in a loop to result
726
+ PyObject *o = SWIG_NewPointerObj (SWIG_as_voidptr (&hostinfo[i]),
727
+ SWIGTYPE_p_hostInfoEnt, 0 | 0 );
728
+ PyList_SetItem (result,i,o);
729
+ }
714
730
731
+ return result;
732
+ }
733
+
715
734
%}
You can’t perform that action at this time.
0 commit comments