本文整理汇总了Python中DIRAC.ResourceStatusSystem.Utilities.Utils.dictMatch方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.dictMatch方法的具体用法?Python Utils.dictMatch怎么用?Python Utils.dictMatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DIRAC.ResourceStatusSystem.Utilities.Utils
的用法示例。
在下文中一共展示了Utils.dictMatch方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __getPolTypes
# 需要导入模块: from DIRAC.ResourceStatusSystem.Utilities import Utils [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Utilities.Utils import dictMatch [as 别名]
def __getPolTypes(self, granularity, status=None, formerStatus=None, newStatus=None,
siteType=None, serviceType=None, resourceType=None):
"""Get Policy Types from config that match the given keyword
arguments"""
# This dict is constructed to be used with function dictMatch that
# helps selecting policies. **kwargs are not used due to the fact
# that it's too dangerous here.
argsdict = {'Granularity': granularity,
'Status': status,
'FormerStatus': formerStatus,
'NewStatus': newStatus,
'SiteType': siteType,
'ServiceType': serviceType,
'ResourceType': resourceType}
pTconfig = getTypedDictRootedAt("PolicyTypes")
pTypes = []
for pt in pTconfig:
if Utils.dictMatch(argsdict, pTconfig[pt]):
pTypes.append(pt)
for pt_name in pTypes:
if 'Alarm_PolType' in pt_name:
pTypes.remove(pt_name)
pTypes.append('Alarm_PolType')
return pTypes
示例2: __getPanelsInfo
# 需要导入模块: from DIRAC.ResourceStatusSystem.Utilities import Utils [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Utilities.Utils import dictMatch [as 别名]
def __getPanelsInfo( self, granularity, statusType = None, status = None,
formerStatus = None, siteType = None, serviceType = None,
resourceType = None, panel_name = None, useNewRes = False ):
info = []
# First, select only policies we want.
argsdict = {'Granularity' : granularity,
'StatusType' : statusType,
'Status' : status,
'FormerStatus' : formerStatus,
'SiteType' : siteType,
'ServiceType' : serviceType,
'ResourceType' : resourceType}
all_policies = getTypedDictRootedAtOperations("Policies")
selected_policies = []
for p in all_policies:
if Utils.dictMatch(argsdict, all_policies[p]):
selected_policies.append(p)
for p in selected_policies: # For selected policies
if panel_name in self.C_Policies[p].keys(): # For selected panel_name (arguments)
toAppend = copy.deepcopy(self.C_Policies[p][panel_name]) # type(toAppend) = list
# Put CommandIn and args to correct values according to useNewRes
if useNewRes:
for panel in toAppend:
for info_type in panel.keys():
if type(panel[info_type]) == dict:
try:
panel[info_type]['CommandIn'] = panel[info_type]['CommandInNewRes']
del panel[info_type]['CommandInNewRes']
except KeyError:
pass
try:
panel[info_type]['args'] = panel[info_type]['argsNewRes']
del panel[info_type]['argsNewRes']
except KeyError:
pass
else:
for panel in toAppend:
for info_type in panel.keys():
try:
del panel[info_type]['CommandInNewRes']
except KeyError:
pass
try:
del panel[info_type]['argsNewRes']
except KeyError:
pass
info.append({p:toAppend})
return info
示例3: __getPolToEval
# 需要导入模块: from DIRAC.ResourceStatusSystem.Utilities import Utils [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Utilities.Utils import dictMatch [as 别名]
def __getPolToEval(self, granularity, status=None, formerStatus=None, siteType=None,
serviceType=None, resourceType=None, useNewRes=False):
# This dict is constructed to be used with function dictMatch that
# helps selecting policies. **kwargs are not used due to the fact
# that it's too dangerous here.
argsdict = {'Granularity': granularity,
'Status': status,
'FormerStatus': formerStatus,
'SiteType': siteType,
'ServiceType': serviceType,
'ResourceType': resourceType}
pConfig = getTypedDictRootedAt("Policies")
pol_to_eval = []
for p in pConfig:
if Utils.dictMatch(argsdict, pConfig[p]):
pol_to_eval.append(p)
polToEval_Args = []
for p in pol_to_eval:
try:
moduleName = self.C_Policies[p]['module']
except KeyError:
moduleName = None
try:
ConfirmationPolicy = self.C_Policies[p]['ConfirmationPolicy']
except KeyError:
ConfirmationPolicy = None
if useNewRes:
try:
commandIn = self.C_Policies[p]['commandInNewRes']
except KeyError:
commandIn = self.C_Policies[p]['commandIn']
try:
args = self.C_Policies[p]['argsNewRes']
except KeyError:
args = self.C_Policies[p]['args']
else:
commandIn = self.C_Policies[p]['commandIn']
args = self.C_Policies[p]['args']
polToEval_Args.append({'Name' : p, 'Module' : moduleName, 'args' : args,
'ConfirmationPolicy' : ConfirmationPolicy,
'commandIn' : commandIn})
return polToEval_Args
示例4: __getPolTypes
# 需要导入模块: from DIRAC.ResourceStatusSystem.Utilities import Utils [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Utilities.Utils import dictMatch [as 别名]
def __getPolTypes( self, granularity, statusType=None, status=None,
formerStatus=None, newStatus=None, siteType=None,
serviceType=None, resourceType=None ):
"""Get Policy Types from config that match the given keyword
arguments. Always returns a generator object, possibly empty."""
# This dict is constructed to be used with function dictMatch that
# helps selecting policies. **kwargs are not used due to the fact
# that it's too dangerous here.
argsdict = {'Granularity' : granularity,
'StatusType' : statusType,
'Status' : status,
'FormerStatus' : formerStatus,
'NewStatus' : newStatus,
'SiteType' : siteType,
'ServiceType' : serviceType,
'ResourceType' : resourceType }
pTconfig = RssConfiguration.getValidPolicyTypes()
return (pt for pt in pTconfig if Utils.dictMatch(argsdict, pTconfig[pt]))
示例5: _getUsersToNotify
# 需要导入模块: from DIRAC.ResourceStatusSystem.Utilities import Utils [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Utilities.Utils import dictMatch [as 别名]
def _getUsersToNotify(self):
groups = CS.getTypedDictRootedAtOperations("AssigneeGroups/" + CS.getSetup()).values()
concerned_groups = [g for g in groups if Utils.dictMatch(self.kw["Params"], g)]
return [{'Users':g['Users'],
'Notifications':g['Notifications']} for g in concerned_groups]