當前位置: 首頁>>代碼示例>>Python>>正文


Python PBSQuery.get_serverinfo方法代碼示例

本文整理匯總了Python中PBSQuery.PBSQuery.get_serverinfo方法的典型用法代碼示例。如果您正苦於以下問題:Python PBSQuery.get_serverinfo方法的具體用法?Python PBSQuery.get_serverinfo怎麽用?Python PBSQuery.get_serverinfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PBSQuery.PBSQuery的用法示例。


在下文中一共展示了PBSQuery.get_serverinfo方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: getModelServers

# 需要導入模塊: from PBSQuery import PBSQuery [as 別名]
# 或者: from PBSQuery.PBSQuery import get_serverinfo [as 別名]
    def getModelServers():
        resultServers = []
        pQuery = PBSQuery()

        try:
            servers = pQuery.get_serverinfo()
            for serverName, pbsServer in servers.items():
                customServer = PBSServer(name=serverName)
                try:
                    customServer.state = TorqueService._listToStr(pbsServer[pbs.ATTR_status], '|')
                except KeyError:
                    pass
                try:
                    customServer.total_jobs = TorqueService._listToInt(pbsServer[pbs.ATTR_total])
                except KeyError:
                    pass
                try:
                    customServer.running_jobs = int(TorqueService._strToDict(pbsServer[pbs.ATTR_count][0])['Running'])
                except KeyError:
                    pass
                try:
                    customServer.queued_jobs = int(TorqueService._strToDict(pbsServer[pbs.ATTR_count][0])['Queued'])
                except KeyError:
                    pass
                try:
                    customServer.pbs_version = TorqueService._listToStr(pbsServer[pbs.ATTR_pbsversion], '|')
                except KeyError:
                    pass

                resultServers.append(customServer)
        except PBSError as pbsErr:
            print(pbsErr)

        return resultServers
開發者ID:dooodlesomething,項目名稱:PyPBS,代碼行數:36,代碼來源:torque_service.py

示例2: main

# 需要導入模塊: from PBSQuery import PBSQuery [as 別名]
# 或者: from PBSQuery.PBSQuery import get_serverinfo [as 別名]
def main():
    pq = PBSQuery()
    print 'Server:',pq.server
    serverinfo = pq.get_serverinfo()
    for k, v in sorted(serverinfo.iteritems()):
        print k 
        for i, j in sorted(v.iteritems()):
            print i, j
開發者ID:prehensilecode,項目名稱:qstatviewer,代碼行數:10,代碼來源:pqserver.py

示例3: __init__

# 需要導入模塊: from PBSQuery import PBSQuery [as 別名]
# 或者: from PBSQuery.PBSQuery import get_serverinfo [as 別名]
 def __init__(self, server_name):
     p = PBSQuery(str(server_name))
     info = p.get_serverinfo().items()[0]
     self.name = info[0]
     self.p = p
     for k,v in info[1].items():
         if k.startswith('resources'):
             for i,j in v.items():
                 setattr(self, k + '_' + i, j[0])
         else:
             setattr(self, k, v[0]) 
開發者ID:VPAC,項目名稱:django-pbs,代碼行數:13,代碼來源:models.py

示例4: __init__

# 需要導入模塊: from PBSQuery import PBSQuery [as 別名]
# 或者: from PBSQuery.PBSQuery import get_serverinfo [as 別名]
  def __init__(self, server, verbosity=0, diagOutputFile=None):
    self.SRList = {}
    self.activeNodes = {}
    self.verbosity = verbosity
    self.server = server

    # Load Torque configuration
    
    try:
        torqueConfig=PBSQuery(server)
        self.server_info=torqueConfig.get_serverinfo()[server]
        self.nodes=torqueConfig.getnodes()
        self.queues=torqueConfig.getqueues()
    except PBSError, e:
        self.__debug(0,"Error connecting to PBS server: %s" % e)
        sys.exit(1)
開發者ID:GRIF,項目名稱:lcg-info-dynamic-maui,代碼行數:18,代碼來源:TorqueMauiConfParser.py

示例5: nicer

# 需要導入模塊: from PBSQuery import PBSQuery [as 別名]
# 或者: from PBSQuery.PBSQuery import get_serverinfo [as 別名]
class QstatViewer:
    """
    Presents a nicer (?) interface to PBSQuery
    The two main member objects are:
    * jobs -- a dictionary with job ID (as str) as the key, 
              and the corresponding Job object as the value
    * nodes -- a dictionary with node name as the key, 
               and a set of corresponding job IDs (of jobs 
               running on node)
    """
    def __init__(self, pbs_server=None, debug_p=False):
        """Creates a QstatViewer object. Arguments:
           - pbs_server : FQDN of the TORQUE server to query (string)"""
        self.debug_p = debug_p

        self.nodes = {}
        self.jobs = {}
        self.queues = {}

        self.pbsquery = PBSQuery(pbs_server)

        self.servername = self.pbsquery.get_server_name()

        self.__make_server()
        self.__make_queues()
        self.__make_jobs()
        self.__make_nodes()


    def __make_nodes(self):
        """Make dict with node names as keys, and list of job objects as values"""

        # make list of jobids running on the node
        #node_jobs = {}
        #for jobid,job in self.jobs.iteritems():
        #    if job.exec_host:
        #        for node_cpu in job.exec_host:
        #            node = node_cpu.split('/')[0]
        #            if node not in node_jobs:
        #                node_jobs[node] = []
        #            else:
        #                node_jobs[node].append(jobid)

        rawnodes = self.pbsquery.getnodes()
        for n,s in rawnodes.iteritems():
            self.nodes[n] = Node(name=n, pbsnodes_dict=dict(s), debug_p=self.debug_p)


    def __make_jobs(self):
        """Make dict with job IDs as keys, and job properties as values"""
        rawjobs = self.pbsquery.getjobs()
        for j,p in rawjobs.iteritems():
            self.jobs[j] = Job(id=j, pbsjobs_dict=dict(p), debug_p=self.debug_p)

    def __make_queues(self):
        """make dict with queue names as keys, and queue properties as values"""
        rawqueues = self.pbsquery.getqueues()
        for q,p in rawqueues.iteritems():
            self.queues[q] = Queue(name=q, pbsqueue_dict=p)

    def __make_server(self):
        self.__serverinfo = self.pbsquery.get_serverinfo()[self.servername]
        if self.debug_p:
            print 'FOOBAR: self.serverinfo =', self.__serverinfo
        for k,v in self.__serverinfo.iteritems():
            self.__dict__[k] = None
            if k == 'state_count':
                # Example of state_count: Transit:0 Queued:-6458 Held:6383 Waiting:0 Running:964 Exiting:0
                self.__dict__[k] = {}
                vals = v[0].strip().split(' ')
                for state in vals:
                    statename = state.split(':')[0]
                    stateval  = int(state.split(':')[1])
                    self.__dict__[k][statename] = stateval
            elif k == 'resources_default':
                v['mem'] = Memory(v['mem'][0])
                v['pmem'] = Memory(v['pmem'][0])
                v['cput'] = pbstimestr_to_timedelta(v['cput'][0])
                v['walltime'] = pbstimestr_to_timedelta(v['walltime'][0])
                self.__dict__[k] = v
            elif k == 'resources_assigned':
                if 'mem' in v:
                    v['mem'] = Memory(v['mem'][0])

                if 'vmem' in v:
                    v['vmem'] = Memory(v['vmem'][0])

                if 'ncpus' in v:
                    v['ncpus'] = int(v['ncpus'][0])
                
                if 'nodect' in v:
                    v['nodect'] = int(v['nodect'][0])

                self.__dict__[k] = v
            elif k == 'scheduling' or k == 'query_other_jobs':
                if v[0] == 'True':
                    v[0] = True
                elif v[0] == 'False':
                    v[0] = False
                self.__dict__[k] = v[0]
#.........這裏部分代碼省略.........
開發者ID:prehensilecode,項目名稱:qstatviewer,代碼行數:103,代碼來源:QstatViewer.py

示例6:

# 需要導入模塊: from PBSQuery import PBSQuery [as 別名]
# 或者: from PBSQuery.PBSQuery import get_serverinfo [as 別名]
#!/usr/bin/python

from PBSQuery import PBSQuery, PBSError
server = 'grid63.lal.in2p3.fr'

try:
    p=PBSQuery(server)
    pbs=p.get_serverinfo()
    nodes=p.getnodes()
    jobs=p.getjobs()
    queues=p.getqueues()
except PBSError, e:
    print "<h3>Error connecting to PBS server:</h3><tt>",e,"</tt>"
    sys.exit(1)


print ""
print "Server info:"
print pbs

print ""
print "Nodes:"
for node in nodes.keys():
  print "********** %s *********" % node
  print nodes[node]

print ""
print "Jobs:"
for job in jobs.keys():
  print "********** Job %s *********" % job
  print jobs[job]
開發者ID:GRIF,項目名稱:lcg-info-dynamic-maui,代碼行數:33,代碼來源:test_pbs_python.py

示例7: pbstimestr_to_timedelta

# 需要導入模塊: from PBSQuery import PBSQuery [as 別名]
# 或者: from PBSQuery.PBSQuery import get_serverinfo [as 別名]
                self.resources_default[res] = pbstimestr_to_timedelta(self.resources_default[res][0])


    def __str__(self):
        outlist = ['Server: {0}'.format(self.name), '\n',
                   '    ACL hosts:    {0}'.format(self.acl_hosts), '\n',
                   '    Scheduling:   {0}'.format(self.scheduling), '\n',
                   '    Managers:     {0}'.format(self.managers), '\n',
                   "    Auth'd users: {0}".format(self.authorized_users), '\n',
                   '    Submit hosts: {0}'.format(self.submit_hosts), '\n',
                   '    Next job no.: {0}'.format(self.next_job_number), '\n',
                   '    Log events:   {0}'.format(self.log_events), '\n',
                   '    Mail from:    {0}'.format(self.mail_from), '\n',
                   '    Query other jobs: {0}'.format(self.query_other_jobs), '\n',
                   '    Resources default: {0}'.format(self.resources_default), '\n',
                   '    Scheduler iteration: {0}'.format(self.scheduler_iteration), '\n',
                   '    Node check rate: {0}'.format(self.node_check_rate), '\n',
                   '    TCP timeout: {0}'.format(self.tcp_timeout), '\n',
                  ]
        retstr = "".join(outlist)
        return retstr


if __name__ == '__main__':
    pq = PBSQuery()

    server = Server(name=pq.server, pbsserver_dict=pq.get_serverinfo())

    print server
    
開發者ID:prehensilecode,項目名稱:qstatviewer,代碼行數:31,代碼來源:Server.py


注:本文中的PBSQuery.PBSQuery.get_serverinfo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。