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


Python Request.LastUpdate方法代码示例

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


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

示例1: test02Props

# 需要导入模块: from DIRAC.RequestManagementSystem.Client.Request import Request [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.Request.Request import LastUpdate [as 别名]
  def test02Props( self ):
    """ props """
    # # valid values
    req = Request()

    req.RequestID = 1
    self.assertEqual( req.RequestID, 1 )

    req.RequestName = "test"
    self.assertEqual( req.RequestName, "test" )

    req.JobID = 1
    self.assertEqual( req.JobID, 1 )

    req.CreationTime = "1970-01-01 00:00:00"
    self.assertEqual( req.CreationTime, datetime.datetime( 1970, 1, 1, 0, 0, 0 ) )
    req.CreationTime = datetime.datetime( 1970, 1, 1, 0, 0, 0 )
    self.assertEqual( req.CreationTime, datetime.datetime( 1970, 1, 1, 0, 0, 0 ) )

    req.SubmitTime = "1970-01-01 00:00:00"
    self.assertEqual( req.SubmitTime, datetime.datetime( 1970, 1, 1, 0, 0, 0 ) )
    req.SubmitTime = datetime.datetime( 1970, 1, 1, 0, 0, 0 )
    self.assertEqual( req.SubmitTime, datetime.datetime( 1970, 1, 1, 0, 0, 0 ) )

    req.LastUpdate = "1970-01-01 00:00:00"
    self.assertEqual( req.LastUpdate, datetime.datetime( 1970, 1, 1, 0, 0, 0 ) )
    req.LastUpdate = datetime.datetime( 1970, 1, 1, 0, 0, 0 )
    self.assertEqual( req.LastUpdate, datetime.datetime( 1970, 1, 1, 0, 0, 0 ) )

    req.Error = ""
开发者ID:JanEbbing,项目名称:DIRAC,代码行数:32,代码来源:RequestTests.py

示例2: getRequest

# 需要导入模块: from DIRAC.RequestManagementSystem.Client.Request import Request [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.Request.Request import LastUpdate [as 别名]
  def getRequest( self, requestName = '', assigned = True ):
    """ read request for execution

    :param str requestName: request's name (default None)
    """
    requestID = None
    log = self.log.getSubLogger( 'getRequest' if assigned else 'peekRequest' )
    if requestName:
      log.verbose( "selecting request '%s'%s" % ( requestName, ' (Assigned)' if assigned else '' ) )
      reqIDQuery = "SELECT `RequestID`, `Status` FROM `Request` WHERE `RequestName` = '%s';" % str( requestName )
      reqID = self._transaction( reqIDQuery )
      if not reqID["OK"]:
        log.error( reqID["Message"] )
        return reqID
      reqID = reqID["Value"].get( reqIDQuery, [] )
      if reqID:
        reqID = reqID[0]
      else:
        reqID = {}
      requestID = reqID.get( "RequestID" )
      status = reqID.get( "Status" )
      if not all( ( requestID, status ) ):
        return S_ERROR( "getRequest: Request '%s' does not exist" % requestName )
      if requestID and status and status == "Assigned" and assigned:
        return S_ERROR( "getRequest: status of request '%s' is 'Assigned', request cannot be selected" % requestName )
    else:
      reqIDsQuery = "SELECT `RequestID` FROM `Request` WHERE `Status` = 'Waiting' ORDER BY `LastUpdate` ASC LIMIT 100;"
      reqAscIDs = self._transaction( reqIDsQuery )
      if not reqAscIDs['OK']:
        log.error( reqAscIDs["Message"] )
        return reqAscIDs
      reqIDs = set( [reqID['RequestID'] for reqID in reqAscIDs["Value"][reqIDsQuery]] )
      reqIDsQuery = "SELECT `RequestID` FROM `Request` WHERE `Status` = 'Waiting' ORDER BY `LastUpdate` DESC LIMIT 50;"
      reqDescIDs = self._transaction( reqIDsQuery )
      if not reqDescIDs['OK']:
        log.error( reqDescIDs["Message"] )
        return reqDescIDs
      reqIDs |= set( [reqID['RequestID'] for reqID in reqDescIDs["Value"][reqIDsQuery]] )
      if not reqIDs:
        return S_OK()
      reqIDs = list( reqIDs )
      random.shuffle( reqIDs )
      requestID = reqIDs[0]

    selectQuery = [ "SELECT * FROM `Request` WHERE `RequestID` = %s;" % requestID,
                    "SELECT * FROM `Operation` WHERE `RequestID` = %s;" % requestID ]
    selectReq = self._transaction( selectQuery )
    if not selectReq["OK"]:
      log.error( selectReq["Message"] )
      return S_ERROR( selectReq["Message"] )
    selectReq = selectReq["Value"]

    request = Request( selectReq[selectQuery[0]][0] )
    origLastUpdate = request.LastUpdate
    if not requestName:
      log.verbose( "selected request '%s'%s" % ( request.RequestName, ' (Assigned)' if assigned else '' ) )
    for records in sorted( selectReq[selectQuery[1]], key = lambda k: k["Order"] ):
      # # order is ro, remove
      del records["Order"]
      operation = Operation( records )
      getFilesQuery = "SELECT * FROM `File` WHERE `OperationID` = %s;" % operation.OperationID
      getFiles = self._transaction( getFilesQuery )
      if not getFiles["OK"]:
        log.error( getFiles["Message"] )
        return getFiles
      getFiles = getFiles["Value"][getFilesQuery]
      for getFile in getFiles:
        getFileDict = dict( [ ( key, value ) for key, value in getFile.items() if value != None ] )
        operation.addFile( File( getFileDict ) )
      request.addOperation( operation )

    request.LastUpdate = origLastUpdate

    if assigned:
      setAssigned = self._transaction( "UPDATE `Request` SET `Status` = 'Assigned', `LastUpdate`=UTC_TIMESTAMP() WHERE RequestID = %s;" % requestID )
      if not setAssigned["OK"]:
        log.error( "%s" % setAssigned["Message"] )
        return setAssigned

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


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