本文整理汇总了Python中DIRAC.RequestManagementSystem.Client.RequestContainer.RequestContainer.getSubRequestTypes方法的典型用法代码示例。如果您正苦于以下问题:Python RequestContainer.getSubRequestTypes方法的具体用法?Python RequestContainer.getSubRequestTypes怎么用?Python RequestContainer.getSubRequestTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DIRAC.RequestManagementSystem.Client.RequestContainer.RequestContainer
的用法示例。
在下文中一共展示了RequestContainer.getSubRequestTypes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setRequest
# 需要导入模块: from DIRAC.RequestManagementSystem.Client.RequestContainer import RequestContainer [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.RequestContainer.RequestContainer import getSubRequestTypes [as 别名]
def setRequest(self, requestName, requestString, desiredStatus=None):
""" Set request to the database (including all sub-requests)
:param self: self reference
:param str requestName: request name
:param str requestString: serilised request
:param mixed desiredState: optional request status, defult = None
"""
self.log.info("setRequest: Attempting to set %s." % requestName)
request = RequestContainer(requestString)
requestTypes = request.getSubRequestTypes()["Value"]
try:
for requestType in requestTypes:
subRequestString = request.toXML(desiredType=requestType)["Value"]
if subRequestString:
if desiredStatus:
status = desiredStatus
elif not request.isRequestTypeEmpty(requestType)["Value"]:
status = "Waiting"
else:
status = "Done"
subRequestDir = os.path.join(self.root, requestType, status)
if not os.path.exists(subRequestDir):
os.makedirs(subRequestDir)
subRequestPath = os.path.join(subRequestDir, requestName)
subRequestFile = open(subRequestPath, "w")
subRequestFile.write(subRequestString)
subRequestFile.close()
self.log.info("setRequest: Successfully set %s." % requestName)
return S_OK()
except Exception, error:
errStr = "setRequest: Exception while setting request."
self.log.exception(errStr, requestName, lException=error)
self.deleteRequest(requestName)
return S_ERROR(errStr)
示例2: setRequest
# 需要导入模块: from DIRAC.RequestManagementSystem.Client.RequestContainer import RequestContainer [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.RequestContainer.RequestContainer import getSubRequestTypes [as 别名]
def setRequest( self, requestName, requestString, desiredStatus = None ):
""" Set request to the database (including all sub-requests)
"""
gLogger.info( "RequestDBFile._setRequest: Attempting to set %s." % requestName )
request = RequestContainer( requestString )
requestTypes = request.getSubRequestTypes()['Value']
try:
for requestType in requestTypes:
subRequestString = request.toXML( desiredType = requestType )['Value']
if subRequestString:
if desiredStatus:
status = desiredStatus
elif not request.isRequestTypeEmpty( requestType )['Value']:
status = 'ToDo'
else:
status = 'Done'
subRequestDir = '%s/%s/%s' % ( self.root, requestType, status )
if not os.path.exists( subRequestDir ):
os.makedirs( subRequestDir )
subRequestPath = '%s/%s' % ( subRequestDir, requestName )
subRequestFile = open( subRequestPath, 'w' )
subRequestFile.write( subRequestString )
subRequestFile.close()
gLogger.info( "RequestDBFile._setRequest: Successfully set %s." % requestName )
return S_OK()
except Exception, x:
errStr = "RequestDBFile._setRequest: Exception while setting request."
gLogger.exception( errStr, requestName, lException = x )
self.deleteRequest( requestName )
return S_ERROR( errStr )
示例3: setRequest
# 需要导入模块: from DIRAC.RequestManagementSystem.Client.RequestContainer import RequestContainer [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.RequestContainer.RequestContainer import getSubRequestTypes [as 别名]
def setRequest( self, requestName, requestString ):
""" insert request :requestName: to teh db
:param str requestName: Requests.RequestName
:param str requestString: xml-serialised request
"""
request = RequestContainer( init = True, request = requestString )
requestTypes = request.getSubRequestTypes()['Value']
failed = False
res = self._getRequestID( requestName )
if not res['OK']:
# we have a special case here: if request already exists, we override it if it
# comes from a DIRAC job. This is identified by having a meaningful JobID in
# the request
if res['Message'].find( 'Duplicate' ) != -1:
# Duplicate request
jobID = request.getJobID()['Value']
if jobID == "Unknown":
return res
try:
jobID = int( jobID )
except:
return res
if jobID > 0:
# Remove the existing request
result = self._deleteRequest( requestName )
if not result['OK']:
message = res['Message']
return S_ERROR( 'Failed to set request: ' + message + ' can not override' )
res = self._getRequestID( requestName )
if not res['OK']:
return res
else:
return res
requestID = res['Value']
subRequestIDs = {}
res = self.__setRequestAttributes( requestID, request )
if res['OK']:
for requestType in requestTypes:
res = request.getNumSubRequests( requestType )
numRequests = res['Value']
for ind in range( numRequests ):
res = self._getSubRequestID( requestID, requestType )
if res['OK']:
subRequestID = res['Value']
res = self.__setSubRequestAttributes( requestID, ind, requestType, subRequestID, request )
if res['OK']:
subRequestIDs[subRequestID] = res['Value']
res = self.__setSubRequestFiles( ind, requestType, subRequestID, request )
if res['OK']:
res = self.__setSubRequestDatasets( ind, requestType, subRequestID, request )
if not res['OK']:
failed = True
message = res['Message']
else:
failed = True
message = res['Message']
else:
failed = True
message = res['Message']
else:
failed = True
message = res['Message']
else:
failed = True
message = res['Message']
for subRequestID, status in subRequestIDs.items():
if not status:
status = "Waiting"
res = self._setSubRequestAttribute( requestID, subRequestID, 'Status', status )
if not res['OK']:
failed = True
message = res['Message']
res = self._setRequestAttribute( requestID, 'Status', 'Waiting' )
if not res['OK']:
failed = True
message = res['Message']
if failed:
res = self._deleteRequest( requestName )
return S_ERROR( 'Failed to set request: ' + message )
else:
return S_OK( requestID )