Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if selector == "Site":
tier1 = gConfig.getValue("/Website/PreferredSites",[])
if len(tier1) > 0:
tier1.sort()
for i in tier1:
if result.has_key(i):
countryCode = i.rsplit(".",1)[1]
c.result.append({"Key":i,"Value":result[i],"Code":countryCode})
for key in keylist:
if selector == "Site" and tier1:
if key not in tier1:
try:
countryCode = key.rsplit(".",1)[1]
except:
countryCode = "Unknown"
c.result.append({"Key":key,"Value":result[key],"Code":countryCode})
elif selector == "Site" and not tier1:
try:
countryCode = key.rsplit(".",1)[1]
except:
countryCode = "Unknown"
c.result.append({"Key":key,"Value":result[key],"Code":countryCode})
else:
c.result.append({"Key":key,"Value":result[key]})
c.result = {"success":"true","result":c.result}
else:
c.result = {"success":"false","error":result["Message"]}
return c.result
################################################################################
result = result["Value"]
gLogger.info("ReS",result)
if result.has_key("TotalRecords"):
if result["TotalRecords"] > 0:
if result.has_key("ParameterNames") and result.has_key("Records"):
if len(result["ParameterNames"]) > 0:
if len(result["Records"]) > 0:
c.result = []
jobs = result["Records"]
head = result["ParameterNames"]
headLength = len(head)
for i in jobs:
tmp = {}
for j in range(0,headLength):
tmp[head[j]] = i[j]
c.result.append(tmp)
total = result["TotalRecords"]
timestamp = Time.dateTime().strftime("%Y-%m-%d %H:%M [UTC]")
if result.has_key("Extras"):
st = self.__dict2string(req)
extra = result["Extras"]
c.result = {"success":"true","result":c.result,"total":total,"extra":extra,"request":st,"date":timestamp}
else:
c.result = {"success":"true","result":c.result,"total":total,"date":timestamp}
else:
c.result = {"success":"false","result":"","error":"There are no data to display"}
else:
c.result = {"success":"false","result":"","error":"ParameterNames field is missing"}
else:
c.result = {"success":"false","result":"","error":"Data structure is corrupted"}
else:
c.result = {"success":"false","result":"","error":"There were no data matching your selection"}
def __getParams(self,id):
try:
id = int(id)
except Exception,x:
c.result = {"success":"false","error":"%s" % str(x)}
return c.result
RPC = getRPCClient("WorkloadManagement/JobMonitoring")
result = RPC.getJobParameters(id)
if result["OK"]:
attr = result["Value"]
c.result = []
for i in attr.items():
if i[0] != "StandardOutput":
c.result.append([i[0],i[1]])
c.result = {"success":"true","result":c.result}
else:
c.result = {"success":"false","error":result["Message"]}
gLogger.info("Params:",id)
return c.result
################################################################################
def __getPending(self,id):
try:
id = int(id)
except Exception,x:
c.result = {"success":"false","error":"%s" % str(x)}
return c.result
RPC = getRPCClient( "RequestManagement/ReqManager" )
result = RPC.readRequestsForJobs( [id] )
if result["OK"]:
c.result = []
if id in result['Value']['Successful']:
req = Request(result['Value']['Successful'][id]).getDigest()['Value']
c.result.append( ["PendingRequest", req] )
c.result = {"success":"true", "result":c.result}
elif id in result['Value']['Failed']: # when no request associated to the job
c.result = {"success":"false", "error":result['Value']["Failed"][id]}
else:
c.result = {"success":"false", "error":"No request found with unknown reason"}
else:
c.result = {"success":"false","error":result["Message"]}
gLogger.info("Params:",id)
return c.result
################################################################################
def __getBasicInfo(self,id):
RPC = getRPCClient("WorkloadManagement/JobMonitoring")
result = RPC.getJobSummary(id)
if result["OK"]:
itemList = result["Value"]
c.result = []
for key,value in itemList.items():
c.result.append([key,value])
c.result = {"success":"true","result":c.result}
else:
c.result = {"success":"false","error":result["Message"]}
gLogger.info("BasicInfo:",id)
return c.result
################################################################################