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


Python RequestContainer.isRequestTypeEmpty方法代码示例

本文整理汇总了Python中DIRAC.RequestManagementSystem.Client.RequestContainer.RequestContainer.isRequestTypeEmpty方法的典型用法代码示例。如果您正苦于以下问题:Python RequestContainer.isRequestTypeEmpty方法的具体用法?Python RequestContainer.isRequestTypeEmpty怎么用?Python RequestContainer.isRequestTypeEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DIRAC.RequestManagementSystem.Client.RequestContainer.RequestContainer的用法示例。


在下文中一共展示了RequestContainer.isRequestTypeEmpty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setRequest

# 需要导入模块: from DIRAC.RequestManagementSystem.Client.RequestContainer import RequestContainer [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.RequestContainer.RequestContainer import isRequestTypeEmpty [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)
开发者ID:hanyl,项目名称:DIRAC,代码行数:37,代码来源:RequestDBFile.py

示例2: setRequest

# 需要导入模块: from DIRAC.RequestManagementSystem.Client.RequestContainer import RequestContainer [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.RequestContainer.RequestContainer import isRequestTypeEmpty [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 )
开发者ID:KrzysztofCiba,项目名称:DIRAC,代码行数:32,代码来源:RequestDBFile.py


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