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


Python ResourceManagementClient.getCachedResult方法代码示例

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


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

示例1: TransferQualityCached_Command

# 需要导入模块: from DIRAC.ResourceStatusSystem.Client.ResourceManagementClient import ResourceManagementClient [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Client.ResourceManagementClient.ResourceManagementClient import getCachedResult [as 别名]
class TransferQualityCached_Command(Command):
  
  def doCommand(self):
    """ 
    Returns transfer quality as it is cached

    :attr:`args`: 
       - args[0]: string: should be a ValidRes
  
       - args[1]: string should be the name of the ValidRes

    :returns:
      {'Result': None | a float between 0.0 and 100.0}
    """
    super(TransferQualityCached_Command, self).doCommand()

    if self.client is None:
      from DIRAC.ResourceStatusSystem.Client.ResourceManagementClient import ResourceManagementClient
      self.client = ResourceManagementClient(timeout = self.timeout)
      
    name = self.args[1]
    
    try:
      res = self.client.getCachedResult(name, 'TransferQualityEverySEs', 'TQ', 'NULL')
      if res == []:
        return {'Result':None}
    except:
      gLogger.exception("Exception when calling ResourceManagementClient for %s" %(name))
      return {'Result':'Unknown'}
    
    return {'Result':float(res[0])}

  doCommand.__doc__ = Command.doCommand.__doc__ + doCommand.__doc__
开发者ID:NathalieRauschmayr,项目名称:DIRAC,代码行数:35,代码来源:DIRACAccounting_Command.py

示例2: PilotsEffSimpleCached_Command

# 需要导入模块: from DIRAC.ResourceStatusSystem.Client.ResourceManagementClient import ResourceManagementClient [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Client.ResourceManagementClient.ResourceManagementClient import getCachedResult [as 别名]
class PilotsEffSimpleCached_Command(Command):
  
  def doCommand(self):
    """ 
    Returns simple pilots efficiency

    :attr:`args`: 
       - args[0]: string: should be a ValidRes
  
       - args[1]: string should be the name of the ValidRes

    returns:
      {
        'Result': 'Good'|'Fair'|'Poor'|'Idle'|'Bad'
      }
    """
    super(PilotsEffSimpleCached_Command, self).doCommand()

    client = self.client

    if client is None:
      from DIRAC.ResourceStatusSystem.Client.ResourceStatusClient import ResourceStatusClient
      self.client = ResourceStatusClient(timeout = self.timeout)
      
    if self.args[0] in ('Service', 'Services'):
      try:
        name = self.client.getGeneralName(self.args[0], self.args[1], 'Site')[0]
      except:
        gLogger.error("PilotsEffSimpleCached_Command: can't get a general name for %s %s" %(self.args[0], self.args[1]))
        return {'Result':'Unknown'}      
      granularity = 'Site'
    elif self.args[0] in ('Site', 'Sites'):
      name = self.args[1]
      granularity = self.args[0]
    else:
      raise InvalidRes, where(self, self.doCommand)
    
    try:
        
      if client is None:  
        from DIRAC.ResourceStatusSystem.Client.ResourceManagementClient import ResourceManagementClient
        self.client = ResourceManagementClient(timeout = self.timeout) 
      res = self.client.getCachedResult(name, 'PilotsEffSimpleEverySites', 'PE_S', 'NULL')
      if res == None:
        return {'Result':'Idle'}
      if res == []:
        return {'Result':'Idle'}
    except:
      gLogger.exception("Exception when calling ResourceManagementClient for %s %s" %(granularity, name))
      return {'Result':'Unknown'}
    
    return {'Result':res[0]}

  doCommand.__doc__ = Command.doCommand.__doc__ + doCommand.__doc__
开发者ID:KrzysztofCiba,项目名称:DIRAC,代码行数:56,代码来源:Pilots_Command.py

示例3: DTInfo_Cached_Command

# 需要导入模块: from DIRAC.ResourceStatusSystem.Client.ResourceManagementClient import ResourceManagementClient [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Client.ResourceManagementClient.ResourceManagementClient import getCachedResult [as 别名]
class DTInfo_Cached_Command(Command):
  
  def doCommand(self):
    """ 
    Returns DT info that are cached.

    :attr:`args`: 
       - args[0]: string: should be a ValidRes
  
       - args[1]: string should be the name of the ValidRes

       - args[2]: string: optional, number of hours in which 
       the down time is starting
    """
    super(DTInfo_Cached_Command, self).doCommand()

    granularity = self.args[0]
    name = self.args[1]

    if self.client is None:
      from DIRAC.ResourceStatusSystem.Client.ResourceManagementClient import ResourceManagementClient
      self.client = ResourceManagementClient( timeout = self.timeout )

    now = datetime.datetime.utcnow().replace( microsecond = 0, second = 0 )
    
    try:
      if granularity in ('Site', 'Sites'):
        commandName = 'DTEverySites'
      elif self.args[0] in ('Resource', 'Resources'):
        commandName = 'DTEveryResources'

      res = self.client.getCachedIDs( name, commandName )
      
      if res[ 'OK' ]:
        res = res[ 'Value' ]    
      else:
        res = []
       
      if len(res) == 0:
        return {'Result':{'DT':None}}

      if len(res) > 1:
        #there's more than one DT
        
        dt_ID_startingSoon = res[0]
        startSTR_startingSoon = self.client.getCachedResult(name, commandName, 
                                                            'StartDate', dt_ID_startingSoon)[ 'Value' ][0]
                                                            
                                                            
        start_datetime_startingSoon = datetime.datetime( *time.strptime(startSTR_startingSoon,
                                                                "%Y-%m-%d %H:%M")[0:5] )
        endSTR_startingSoon = self.client.getCachedResult(name, commandName, 
                                                          'EndDate', dt_ID_startingSoon)[ 'Value' ][0]
        end_datetime_startingSoon = datetime.datetime( *time.strptime(endSTR_startingSoon,
                                                             "%Y-%m-%d %H:%M")[0:5] )
        
        if start_datetime_startingSoon < now:
          if end_datetime_startingSoon > now:
            #ongoing downtime found!
            DT_ID = dt_ID_startingSoon
        
        try:
          DT_ID
        except:
          for dt_ID in res[1:]:
            #looking for an ongoing one
            startSTR = self.client.getCachedResult(name, commandName, 'StartDate', dt_ID)['Value'][0]
            start_datetime = datetime.datetime( *time.strptime(startSTR, "%Y-%m-%d %H:%M")[0:5] )
            endSTR = self.client.getCachedResult(name, commandName, 'EndDate', dt_ID)['Value'][0]
            end_datetime = datetime.datetime( *time.strptime(endSTR, "%Y-%m-%d %H:%M")[0:5] )

            if start_datetime < now:
              if end_datetime > now:
                #ongoing downtime found!
                DT_ID = dt_ID
              break
            if start_datetime < start_datetime_startingSoon:
              #the DT starts before the former considered one
              dt_ID_startingSoon = dt_ID
          try:
            DT_ID
          except:
            #if I'm here, there's no OnGoing DT
            DT_ID = dt_ID_startingSoon

      else:
        DT_ID = res[0]

      DT_dict_result = {}

      endSTR = self.client.getCachedResult(name, commandName, 'EndDate', DT_ID)['Value'][0]
      end_datetime = datetime.datetime( *time.strptime(endSTR, "%Y-%m-%d %H:%M")[0:5] )
      if end_datetime < now:
        return {'Result': {'DT':None}}
      DT_dict_result['EndDate'] = endSTR
      DT_dict_result['DT'] = self.client.getCachedResult(name, commandName, 'Severity', DT_ID)['Value'][0]
      DT_dict_result['StartDate'] = self.client.getCachedResult(name, commandName, 'StartDate', DT_ID)['Value'][0]
      DT_dict_result['Description'] = self.client.getCachedResult(name, commandName, 'Description', DT_ID)['Value'][0]
      DT_dict_result['Link'] = self.client.getCachedResult(name, commandName, 'Link', DT_ID)['Value'][0]
      startSTR = self.client.getCachedResult(name, commandName, 'StartDate', DT_ID)['Value'][0]
#.........这里部分代码省略.........
开发者ID:caitriana,项目名称:DIRAC,代码行数:103,代码来源:GOCDBStatus_Command.py


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