本文整理汇总了Python中DIRAC.ResourceStatusSystem.Client.ResourceStatusClient.ResourceStatusClient.getMonitoredsStatusWeb方法的典型用法代码示例。如果您正苦于以下问题:Python ResourceStatusClient.getMonitoredsStatusWeb方法的具体用法?Python ResourceStatusClient.getMonitoredsStatusWeb怎么用?Python ResourceStatusClient.getMonitoredsStatusWeb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DIRAC.ResourceStatusSystem.Client.ResourceStatusClient.ResourceStatusClient
的用法示例。
在下文中一共展示了ResourceStatusClient.getMonitoredsStatusWeb方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: submit
# 需要导入模块: from DIRAC.ResourceStatusSystem.Client.ResourceStatusClient import ResourceStatusClient [as 别名]
# 或者: from DIRAC.ResourceStatusSystem.Client.ResourceStatusClient.ResourceStatusClient import getMonitoredsStatusWeb [as 别名]
def submit(self):
pagestart = time()
RPC = getRPCClient( "ResourceStatus/ResourceStatus" )
client = ResourceStatusClient( serviceIn = RPC )
if not request.params.has_key("mode") or not len(request.params["mode"]) > 0:
gLogger.error("The parameter 'mode' is absent")
return {"success":"false","error":"The parameter 'mode' is absent"}
mode = request.params["mode"]
gLogger.verbose("Requested mode is %s" % mode)
if not mode in MODELIST:
gLogger.error("Parameter 'mode': %s is wrong. Should be one of the list %s" % (mode, MODELIST) )
return {"success":"false","error":"Parameter 'mode' is wrong"}
if mode in STORELIST:
mode = 'StorageElement'
gLogger.verbose("Selected mode is %s" % mode)
req = self.__request()
gLogger.info("getMonitoredsStatusWeb(%s,%s,%s,%s)" % (mode,req,P_NUMBER,R_NUMBER))
result = client.getMonitoredsStatusWeb(mode,req,P_NUMBER,R_NUMBER)
gLogger.debug("Call result: %s" % result )
if not result["OK"]:
error = result["Message"]
gLogger.error( error )
return {"success":"false","error":error}
result = result["Value"]
if not result.has_key("TotalRecords") or not result["TotalRecords"] > 0:
return {"success":"false","error":"There were no data matching your selection"}
if not result.has_key("ParameterNames") or not result.has_key("Records"):
return {"success":"false","error":"Data structure is corrupted"}
if not len(result["ParameterNames"]) > 0:
return {"success":"false","error":"ParameterNames field is undefined"}
if not len(result["Records"]) > 0:
return {"success":"false","error":"There are no data to display"}
c.result = []
records = result["Records"]
head = result["ParameterNames"]
headLength = len(head)
countryCode = self.__countries()
for i in records:
tmp = {}
for j in range(0,headLength):
tmp[head[j]] = i[j]
if mode == "Resource":
if countryCode.has_key(i[4]):
tmp["FullCountry"] = countryCode[i[4]]
else:
tmp["Country"] = "Unknown"
tmp["FullCountry"] = "Unknown"
else:
if countryCode.has_key(i[3]):
tmp["FullCountry"] = countryCode[i[3]]
else:
tmp["Country"] = "Unknown"
tmp["FullCountry"] = "Unknown"
c.result.append(tmp)
total = result["TotalRecords"]
if result.has_key("Extras"):
extra = result["Extras"]
c.result = {"success":"true","result":c.result,"total":total,"extra":extra}
else:
c.result = {"success":"true","result":c.result,"total":total}
return c.result