本文整理汇总了Python中DIRAC.RequestManagementSystem.Client.RequestContainer.RequestContainer.getRequestAttributes方法的典型用法代码示例。如果您正苦于以下问题:Python RequestContainer.getRequestAttributes方法的具体用法?Python RequestContainer.getRequestAttributes怎么用?Python RequestContainer.getRequestAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DIRAC.RequestManagementSystem.Client.RequestContainer.RequestContainer
的用法示例。
在下文中一共展示了RequestContainer.getRequestAttributes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __getRequestString
# 需要导入模块: from DIRAC.RequestManagementSystem.Client.RequestContainer import RequestContainer [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.RequestContainer.RequestContainer import getRequestAttributes [as 别名]
def __getRequestString(self, requestName):
""" Obtain the string for request (including all sub-requests)
:param self: self reference
:param str requestName: request name
"""
self.log.info("__getRequestString: Attempting to get string for %s." % requestName)
res = self.__locateRequest(requestName)
if not res["OK"]:
return res
subRequestPaths = res["Value"]
try:
oRequest = RequestContainer(init=False)
for subRequestPath in subRequestPaths:
res = self.__readSubRequestString(subRequestPath)
if not res["OK"]:
return res
subRequestString = res["Value"]
tempRequest = RequestContainer(subRequestString)
oRequest.setRequestAttributes(tempRequest.getRequestAttributes()["Value"])
oRequest.update(tempRequest)
requestString = oRequest.toXML()["Value"]
self.log.info("__getRequestString: Successfully obtained string for %s." % requestName)
result = S_OK(requestString)
result["Request"] = oRequest
return result
except Exception, error:
errStr = "__getRequestString: Exception while obtaining request string."
self.log.exception(errStr, requestName, lException=error)
return S_ERROR(errStr)
示例2: __getRequestString
# 需要导入模块: from DIRAC.RequestManagementSystem.Client.RequestContainer import RequestContainer [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.RequestContainer.RequestContainer import getRequestAttributes [as 别名]
def __getRequestString( self, requestName ):
""" Obtain the string for request (including all sub-requests)
"""
gLogger.info( "RequestDBFile.__getRequestString: Attempting to get string for %s." % requestName )
res = self.__locateRequest( requestName )
if not res['OK']:
return res
subRequestPaths = res['Value']
try:
oRequest = RequestContainer( init = False )
for subRequestPath in subRequestPaths:
res = self.__readSubRequestString( subRequestPath )
if not res['OK']:
return res
subRequestString = res['Value']
tempRequest = RequestContainer( subRequestString )#,init=False)
oRequest.setRequestAttributes( tempRequest.getRequestAttributes()['Value'] )
oRequest.update( tempRequest )
requestString = oRequest.toXML()['Value']
gLogger.info( "RequestDBFile.__getRequestString: Successfully obtained string for %s." % requestName )
result = S_OK( requestString )
result['Request'] = oRequest
return result
except Exception, x:
errStr = "RequestDBFile.__getRequestString: Exception while obtaining request string."
gLogger.exception( errStr, requestName, lException = x )
return S_ERROR( errStr )
示例3: execute_request
# 需要导入模块: from DIRAC.RequestManagementSystem.Client.RequestContainer import RequestContainer [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.RequestContainer.RequestContainer import getRequestAttributes [as 别名]
def execute_request( self ):
""" Takes one DISET request and forward it to the destination service
"""
gMonitor.addMark( "Iteration", 1 )
if self.RequestDB:
res = self.RequestDB.getRequest( 'diset' )
else:
res = self.RequestDBClient.getRequest( 'diset' )
if not res['OK']:
gLogger.error( "DISETForwardingAgent.execute: Failed to get request from database." )
return S_OK()
elif not res['Value']:
gLogger.info( "DISETForwardingAgent.execute: No requests to be executed found." )
return S_OK()
gMonitor.addMark( "Attempted", 1 )
requestString = res['Value']['RequestString']
requestName = res['Value']['RequestName']
try:
jobID = int( res['Value']['JobID'] )
except:
jobID = 0
gLogger.info( "DISETForwardingAgent.execute: Obtained request %s" % requestName )
if self.RequestDB:
result = self.RequestDB._getRequestAttribute( 'RequestID', requestName = requestName )
if not result['OK']:
return S_OK( 'Can not get the request execution order' )
requestID = result['Value']
result = self.RequestDB.getCurrentExecutionOrder( requestID )
else:
result = self.RequestDBClient.getCurrentExecutionOrder( requestName )
if result['OK']:
currentOrder = result['Value']
else:
return S_OK( 'Can not get the request execution order' )
oRequest = RequestContainer( request = requestString )
requestAttributes = oRequest.getRequestAttributes()['Value']
################################################
# Find the number of sub-requests from the request
res = oRequest.getNumSubRequests( 'diset' )
if not res['OK']:
errStr = "DISETForwardingAgent.execute: Failed to obtain number of diset subrequests."
gLogger.error( errStr, res['Message'] )
return S_OK()
gLogger.info( "DISETForwardingAgent.execute: Found %s sub requests for job %s" % ( res['Value'], jobID ) )
################################################
# For all the sub-requests in the request
modified = False
for ind in range( res['Value'] ):
subRequestAttributes = oRequest.getSubRequestAttributes( ind, 'diset' )['Value']
subExecutionOrder = int( subRequestAttributes['ExecutionOrder'] )
subStatus = subRequestAttributes['Status']
gLogger.info( "DISETForwardingAgent.execute: Processing sub-request %s with execution order %d" % ( ind, subExecutionOrder ) )
if subStatus == 'Waiting' and subExecutionOrder <= currentOrder:
operation = subRequestAttributes['Operation']
gLogger.info( "DISETForwardingAgent.execute: Attempting to forward %s type." % operation )
rpcStubString = subRequestAttributes['Arguments']
rpcStub, length = DEncode.decode( rpcStubString )
res = executeRPCStub( rpcStub )
if res['OK']:
gLogger.info( "DISETForwardingAgent.execute: Successfully forwarded." )
oRequest.setSubRequestStatus( ind, 'diset', 'Done' )
gMonitor.addMark( "Successful", 1 )
modified = True
elif res['Message'] == 'No Matching Job':
gLogger.warn( "DISETForwardingAgent.execute: No corresponding job found. Setting to done." )
oRequest.setSubRequestStatus( ind, 'diset', 'Done' )
else:
gLogger.error( "DISETForwardingAgent.execute: Failed to forward request.", res['Message'] )
else:
gLogger.info( "DISETForwardingAgent.execute: Sub-request %s is status '%s' and not to be executed." % ( ind, subRequestAttributes['Status'] ) )
################################################
# Generate the new request string after operation
requestString = oRequest.toXML()['Value']
if self.RequestDB:
res = self.RequestDB.updateRequest( requestName, requestString )
else:
res = self.RequestDBClient.updateRequest( requestName, requestString )
if res['OK']:
gLogger.info( "DISETForwardingAgent.execute: Successfully updated request." )
else:
gLogger.error( "DISETForwardingAgent.execute: Failed to update request" )
if modified and jobID:
result = self.RequestDBClient.finalizeRequest( requestName, jobID )
return S_OK()