当前位置: 首页>>代码示例>>Python>>正文


Python CommonUtils.convertTimeLimit方法代码示例

本文整理汇总了Python中CommonUtils.convertTimeLimit方法的典型用法代码示例。如果您正苦于以下问题:Python CommonUtils.convertTimeLimit方法的具体用法?Python CommonUtils.convertTimeLimit怎么用?Python CommonUtils.convertTimeLimit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CommonUtils的用法示例。


在下文中一共展示了CommonUtils.convertTimeLimit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

# 需要导入模块: import CommonUtils [as 别名]
# 或者: from CommonUtils import convertTimeLimit [as 别名]
    def run(self):
        line = self.stream.readline()
        
        while line:
            try:
                           
                line = line.strip()
                
                if len(line) == 0:
                    continue
                    
                qTuple = line.split()
                
                if len(qTuple) <> 9:
                    self.errList.append("Wrong partition info column number: %d" % len(qTuple))
                    continue
                
                queue = qTuple[0]
                if queue.endswith('*'):
                    queue = queue[:-1]
                if not queue in self.qtable:
                    self.qtable[queue] = PartitionInfo()
                    
                if qTuple[1] == 'down' or qTuple[1] == 'inactive':
                    self.qtable[queue].state = 'Closed'
                elif qTuple[1] == 'drain':
                    self.qtable[queue].state = 'Draining'
                else:
                    self.qtable[queue].state = 'Production'
                
                parsed = self.cpuRegex.match(qTuple[2])
                if not parsed:
                    self.errList.append("Wrong format for partition cpu info: " + qTuple[2])
                    continue
                self.qtable[queue].freeCPU = int(parsed.group(2))
                self.qtable[queue].activeCPU = int(parsed.group(1))
                self.qtable[queue].totalCPU = int(parsed.group(4))
                
                if qTuple[3] <> 'n/a':
                    self.qtable[queue].maxRuntime = CommonUtils.convertTimeLimit(qTuple[3])
                
                if qTuple[4] <> 'n/a':
                    self.qtable[queue].defaultRuntime = CommonUtils.convertTimeLimit(qTuple[4])
                elif self.qtable[queue].maxRuntime <> -1:
                    self.qtable[queue].defaultRuntime = self.qtable[queue].maxRuntime
                    
                try:
                    minNodes, maxNodes = CommonUtils.convertJobSize(qTuple[5])
                    
                    if maxNodes < 0:
                        continue
                    
                    if qTuple[7].lower() <> 'unlimited':
                    
                        maxCPUNode = int(qTuple[7])
                        self.qtable[queue].slotsPerJob = maxNodes * maxCPUNode
                        
                    else:
                        tmpl = [ i.translate(None, '+') for i in qTuple[8].split(':') ]                        
                        socketNum = int(tmpl[0])
                        coreNum = int(tmpl[1])
                        thrNum = int(tmpl[2])
                        self.qtable[queue].slotsPerJob = maxNodes * socketNum * coreNum * thrNum
                        
                except Exception, ex:
                    logger.debug("Cannot calculate MaxSlotsPerJob for %s", queue, exc_info=True)
                    self.errList.append("Cannot calculate MaxSlotsPerJob for %s" % queue)

                                
            finally:
                line = self.stream.readline()
开发者ID:italiangrid,项目名称:info-dynamic-scheduler-slurm,代码行数:73,代码来源:SInfoHandler.py


注:本文中的CommonUtils.convertTimeLimit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。