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 @@ -707,6 +707,25 @@ PyObject * get_pids_from_stream(struct jRusage * jrusage) {
707707 PyList_SetItem (result, i, o);
708708 }
709709 return result;
710- }
710+ }
711+
712+ PyObject * get_host_info_all () {
713+ struct hostInfoEnt *hostinfo;
714+ char **hosts = NULL ;
715+ int numhosts = 0 ;
716+
717+ // Return queries as C hostInfoEnt*
718+ hostinfo = lsb_hostinfo (hosts, &numhosts);
719+
720+ PyObject *result = PyList_New (numhosts); // Create PyObject * to get C returns
721+ int i;
722+ for (i = 0 ; i < numhosts; i++) { // Save queries in a loop to result
723+ PyObject *o = SWIG_NewPointerObj (SWIG_as_voidptr (&hostinfo[i]),
724+ SWIGTYPE_p_hostInfoEnt, 0 | 0 );
725+ PyList_SetItem (result,i,o);
726+ }
727+
728+ return result;
729+ }
711730
712731%}
You can’t perform that action at this time.
0 commit comments