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


Python Request.tableDesc方法代码示例

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


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

示例1: test01TableDesc

# 需要导入模块: from DIRAC.RequestManagementSystem.Client.Request import Request [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.Request.Request import tableDesc [as 别名]
 def test01TableDesc(self):
     """ table description """
     tableDict = RequestDB.getTableMeta()
     self.assertEqual("Request" in tableDict, True)
     self.assertEqual("Operation" in tableDict, True)
     self.assertEqual("File" in tableDict, True)
     self.assertEqual(tableDict["Request"], Request.tableDesc())
     self.assertEqual(tableDict["Operation"], Operation.tableDesc())
     self.assertEqual(tableDict["File"], File.tableDesc())
开发者ID:sposs,项目名称:DIRAC,代码行数:11,代码来源:RequestDBTests.py

示例2: test_db

# 需要导入模块: from DIRAC.RequestManagementSystem.Client.Request import Request [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.Request.Request import tableDesc [as 别名]
  def test_db( self ):

    """ table description """
    tableDict = RequestDB.getTableMeta()
    self.assertEqual( "Request" in tableDict, True )
    self.assertEqual( "Operation" in tableDict, True )
    self.assertEqual( "File" in tableDict, True )
    self.assertEqual( tableDict["Request"], Request.tableDesc() )
    self.assertEqual( tableDict["Operation"], Operation.tableDesc() )
    self.assertEqual( tableDict["File"], File.tableDesc() )

    # # empty DB at that stage
    ret = RequestDB().getDBSummary()
    self.assertEqual( ret,
                      { 'OK': True,
                        'Value': { 'Operation': {}, 'Request': {}, 'File': {} } } )
开发者ID:zimmerst,项目名称:TestDIRAC,代码行数:18,代码来源:TestClientReq.py

示例3: _getRequestProperties

# 需要导入模块: from DIRAC.RequestManagementSystem.Client.Request import Request [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.Request.Request import tableDesc [as 别名]
 def _getRequestProperties( self, requestName, columnNames = None ):
   """ select :columnNames: from Request table  """
   columnNames = columnNames if columnNames else Request.tableDesc()["Fields"].keys()
   columnNames = ",".join( [ '`%s`' % str( columnName ) for columnName in columnNames ] )
   return "SELECT %s FROM `Request` WHERE `RequestName` = `%s`;" % ( columnNames, requestName )
开发者ID:IgorPelevanyuk,项目名称:DIRAC,代码行数:7,代码来源:RequestDB.py

示例4: getBulkRequests

# 需要导入模块: from DIRAC.RequestManagementSystem.Client.Request import Request [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.Request.Request import tableDesc [as 别名]
  def getBulkRequests( self, numberOfRequest = 10, assigned = True ):
    """ read as many requests as requested for execution

    :param int numberOfRequest: Number of Request we want (default 10)
    :param bool assigned: if True, the status of the selected requests are set to assign

    :returns a dictionary of Request objects indexed on the RequestID

    """

    # r_RequestID : RequestID, r_LastUpdate : LastUpdate...
    requestAttrDict = dict ( ( "r_%s" % r, r ) for r in Request.tableDesc()["Fields"] )
    # o_RequestID : RequestID, o_OperationID : OperationID...
    operationAttrDict = dict ( ( "o_%s" % o, o ) for o in Operation.tableDesc()["Fields"] )
    # f_OperationID : OperationID, f_FileID : FileID...
    fileAttrDict = dict ( ( "f_%s" % f, f ) for f in File.tableDesc()["Fields"] )

    # o.OperationID as o_OperationID, ..., r_RequestID, ..., f_FileID, ...
    allFieldsStr = ",".join( [ "o.%s as %s" % ( operationAttrDict[o], o ) for o in operationAttrDict]\
                            + requestAttrDict.keys() + fileAttrDict.keys() )

    # RequestID as r_RequestID, LastUpdate as r_LastUpdate, ...
    requestAttrStr = ",".join( [ "%s as %s" % ( requestAttrDict[r], r ) for r in requestAttrDict] )

    # OperationID as f_OperationID, FileID as f_FileID...
    fileAttrStr = ",".join( [ "%s as %s" % ( fileAttrDict[f], f ) for f in fileAttrDict] )


    # Selects all the Request (limited to numberOfRequest, sorted by LastUpdate) , Operation and File information.
    # The entries are sorted by the LastUpdate of the Requests, RequestID if several requests were update the last time
    # at the same time, and finally according to the Operation Order
    query = "SELECT %s FROM Operation o \
            INNER JOIN (SELECT %s FROM Request WHERE Status = 'Waiting' ORDER BY `LastUpdate` ASC limit %s) r\
            ON r_RequestID = o.RequestID\
            INNER JOIN (SELECT %s from File) f ON f_OperationId = o.OperationId\
            ORDER BY r_LastUpdate, r_RequestId, o_Order;"\
             % ( allFieldsStr, requestAttrStr, numberOfRequest, fileAttrStr )

    queryResult = self._transaction( query )
    if not queryResult["OK"]:
      self.log.error( "RequestDB.getRequests: %s" % queryResult["Message"] )
      return queryResult

    allResults = queryResult["Value"][query]

    # We now construct a dict of Request indexed by their ID, and the same for Operation

    requestDict = {}
    operationDict = {}
    for entry in allResults:
      requestID = int( entry["r_RequestID"] )
      # If the object already exists, we get it, otherwise we create it and assign it
      requestObj = requestDict.setdefault( requestID, Request( dict( ( requestAttrDict[r], entry[r] ) for r in requestAttrDict ) ) )

      operationID = int( entry["o_OperationID"] )
      operationObj = operationDict.get( operationID, None )

      # If the Operation object does not exist yet, we create it, and add it to the Request
      if not operationObj:
        operationObj = Operation( dict( ( operationAttrDict[o], entry[o] ) for o in operationAttrDict ) )
        operationDict[operationID ] = operationObj
        requestObj.addOperation( operationObj )

      fileObj = File( dict( ( fileAttrDict[f], entry[f] ) for f in fileAttrDict ) )
      operationObj.addFile( fileObj )


    if assigned and len( requestDict ):
      listOfReqId = ",".join( str( rId ) for rId in requestDict )
      setAssigned = self._transaction( "UPDATE `Request` SET `Status` = 'Assigned' WHERE RequestID IN (%s);" % listOfReqId )
      if not setAssigned["OK"]:
        self.log.error( "getRequests: %s" % setAssigned["Message"] )
        return setAssigned

    return S_OK( requestDict )
开发者ID:Teddy22,项目名称:DIRAC,代码行数:77,代码来源:RequestDB.py


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