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


Python ResourceStatusClient.getMonitoredsStatusWeb方法代码示例

本文整理汇总了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
开发者ID:DIRACGrid,项目名称:DIRACWeb,代码行数:63,代码来源:SiteGateway.py


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