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


Python ResourceManagementClient.getCachedAccountingResult方法代码示例

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


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

示例1: TransferQualityFromCachedPlot_Command

# 需要导入模块: from DIRAC.ResourceStatusSystem.Client.ResourceManagementClient import ResourceManagementClient [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Client.ResourceManagementClient.ResourceManagementClient import getCachedAccountingResult [as 别名]
class TransferQualityFromCachedPlot_Command(Command):
  
  def doCommand(self):
    """ 
    Returns transfer quality from the plot cached in the accounting cache.

    :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(TransferQualityFromCachedPlot_Command, self).doCommand()

    if self.client is None:
      from DIRAC.ResourceStatusSystem.Client.ResourceManagementClient import ResourceManagementClient
      self.client = ResourceManagementClient(timeout = self.timeout)
      
    granularity = self.args[0]
    name = self.args[1]
    plotType = self.args[2]
    plotName = self.args[3]
    
    try:
      res = self.client.getCachedAccountingResult(name, plotType, plotName)

      res = res[ 'Value' ]

      if res == []:
        return {'Result':None}
      res = eval(res[0])
      
      s = 0
      n = 0
      
      try:
        SE = res['data'].keys()[0]
      except IndexError:
        return {'Result':None}  
      
      n = n + len(res['data'][SE])
      s = s + sum(res['data'][SE].values())
      meanQuality = s/n
      
    except:
      gLogger.exception("Exception when calling ResourcePolicyClient for %s" %(name))
      return {'Result':'Unknown'}
    
    return {'Result':meanQuality}

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

示例2: CachedPlot_Command

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

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

       - args[2]: string - should be the plot type

       - args[3]: string - should be the plot name

    :returns:
      a plot
    """
    super(CachedPlot_Command, self).doCommand()

    if self.client is None:
      from DIRAC.ResourceStatusSystem.Client.ResourceManagementClient import ResourceManagementClient
      self.client = ResourceManagementClient(timeout = self.timeout)
      
    granularity = self.args[0]
    name = self.args[1]
    plotType = self.args[2]
    plotName = self.args[3]
    
    if granularity == 'Service':
      name = name.split('@')[1]
    
    try:
      res = self.client.getCachedAccountingResult(name, plotType, plotName)
      if res == []:
        return {'Result':{'data':{}, 'granularity':900}}
    except:
      gLogger.exception("Exception when calling ResourcePolicyClient for %s" %(name))
      return {'Result':'Unknown'}
    
    return {'Result':eval(res[0])}

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


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