本文整理汇总了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__
示例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__