Пример #1
0
 def pbsnodes(self, grouping=None, keyformatter=lambda x: x):
     stdout, stderr, ret = tandem_utils.call([self._bin("pbsnodes"), "-a", "-F", "json"])
     
     if ret == 1 and 'Server has no node list' in stderr:
         return {None: {}}
     
     if ret != 0:
         raise RuntimeError(stderr)
     
     nodes = json.loads(stdout)["nodes"]
     
     if not grouping:
         return {None: nodes}
     
     if isinstance(grouping, basestring):
         grouping = (grouping, )
     
     grouped = OrderedDict()
     for _node_name, node in nodes.iteritems():
         res_avail = node["resources_available"]
         
         def flat_get(node, g):
             return res_avail.get(g, node.get(g))
         
         key = keyformatter(tuple([flat_get(node, g) for g in grouping]))
         if key not in grouped:
             grouped[key] = []
         grouped[key].append(node)
         
     return grouped
 def _jobstatus(self, local_job_id_query=None):
     stdout, stderr, code = tandem_utils.call(
         self.qstat_args(local_job_id_query))
     if hasattr(stdout, "decode"):
         stdout = stdout.decode()
         stderr = stderr.decode()
     return stdout, stderr, code, _from_qstat
Пример #3
0
 def _get_jobs(self, args):
     stdout, stderr, code = tandem_utils.call(args)
     if code == 0:
         return stdout, _from_qstat
     elif code == _PBS_NOT_FOUND:
         return "[]", json.loads
     else:
         tandem_utils.error_and_exit(stderr)
Пример #4
0
 def _hold_release_remove(self, cmd, local_job_ids):
     out, err, code = tandem_utils.call([cmd] + local_job_ids)
     if code == 0:
         return {"status": "success"}
     elif code == _PBS_NOT_FOUND:
         return {"status": "not_found", "details": err}
     else:
         return {"status": "error", "details": err}
Пример #5
0
 def _jobstatus(self, local_job_id_query=None):
     stdout, stderr, code = tandem_utils.call(self.qstat_args(local_job_id_query))
     return stdout, stderr, code, _from_qstat