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


Python Request.insertBefore方法代码示例

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


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

示例1: createRequest

# 需要导入模块: from DIRAC.RequestManagementSystem.Client.Request import Request [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.Request.Request import insertBefore [as 别名]
def createRequest( reqType ):
  r = Request()

  # Simple failover
  op1 = Operation()
  f = File()
  f.LFN = '/This/is/an/LFN'
  op1.addFile( f )
  op1.Type = 'ReplicateAndRegister'
  op1.SourceSE = 'CERN-FAILOVER'
  op1.TargetSE = 'CERN-BUFFER'
  r.addOperation( op1 )
  op2 = Operation()
  op2.addFile( f )
  op2.Type = 'RemoveReplica'
  op2.TargetSE = 'CERN-FAILOVER'
  r.addOperation( op2 )
  if reqType == 0:
    return r

  # two files for Failover
  f1 = File()
  f1.LFN = '/This/is/a/second/LFN'
  op3 = Operation()
  op3.addFile( f1 )
  op3.Type = 'ReplicateAndRegister'
  op3.SourceSE = 'CERN-FAILOVER'
  op3.TargetSE = 'CERN-BUFFER'
  r.addOperation( op3 )
  op3 = Operation()
  op3.addFile( f1 )
  op3.Type = 'RemoveReplica'
  op3.TargetSE = 'CERN-FAILOVER'
  r.addOperation( op3 )
  if reqType == 1:
    return r

  op = Operation()
  op.Type = 'ForwardDiset'
  if reqType == 2:
    r.addOperation( op )
    return r

  r.insertBefore( op, r[0] )
  if reqType == 3:
    return r

  op4 = Operation()
  op4.Type = 'ForwardDiset'
  r.addOperation( op4 )
  if reqType == 4:
    return r

  # 2 different FAILOVER SEs: removal not optimized
  r[1].SourceSE = 'RAL-FAILOVER'
  r[2].SourceSE = 'RAL-FAILOVER'
  if reqType == 5:
    return r

  # 2 different destinations, same FAILOVER: replication not optimized
  r[3].SourceSE = 'RAL-FAILOVER'
  r[4].SourceSE = 'RAL-FAILOVER'
  r[3].TargetSE = 'RAL-BUFFER'
  if reqType == 6:
    return r

  print 'This should not happen, reqType =', reqType
开发者ID:JanEbbing,项目名称:DIRAC,代码行数:69,代码来源:RequestTests.py

示例2: test05FTS

# 需要导入模块: from DIRAC.RequestManagementSystem.Client.Request import Request [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.Request.Request import insertBefore [as 别名]
  def test05FTS( self ):
    """ FTS state machine """

    req = Request()
    req.RequestName = "FTSTest"

    ftsTransfer = Operation()
    ftsTransfer.Type = "ReplicateAndRegister"
    ftsTransfer.TargetSE = "CERN-USER"

    ftsFile = File()
    ftsFile.LFN = "/a/b/c"
    ftsFile.Checksum = "123456"
    ftsFile.ChecksumType = "Adler32"

    ftsTransfer.addFile( ftsFile )
    req.addOperation( ftsTransfer )

    self.assertEqual( req.Status, "Waiting", "1. wrong request status: %s" % req.Status )
    self.assertEqual( ftsTransfer.Status, "Waiting", "1. wrong ftsStatus status: %s" % ftsTransfer.Status )

    # # scheduled
    ftsFile.Status = "Scheduled"

    self.assertEqual( ftsTransfer.Status, "Scheduled", "2. wrong status for ftsTransfer: %s" % ftsTransfer.Status )
    self.assertEqual( req.Status, "Scheduled", "2. wrong status for request: %s" % req.Status )

    # # add new operation before FTS
    insertBefore = Operation()
    insertBefore.Type = "RegisterReplica"
    insertBefore.TargetSE = "CERN-USER"
    insertFile = File()
    insertFile.LFN = "/a/b/c"
    insertFile.PFN = "http://foo/bar"
    insertBefore.addFile( insertFile )
    req.insertBefore( insertBefore, ftsTransfer )

    self.assertEqual( insertBefore.Status, "Waiting", "3. wrong status for insertBefore: %s" % insertBefore.Status )
    self.assertEqual( ftsTransfer.Status, "Scheduled", "3. wrong status for ftsStatus: %s" % ftsTransfer.Status )
    self.assertEqual( req.Status, "Waiting", "3. wrong status for request: %s" % req.Status )

    # # prev done
    insertFile.Status = "Done"

    self.assertEqual( insertBefore.Status, "Done", "4. wrong status for insertBefore: %s" % insertBefore.Status )
    self.assertEqual( ftsTransfer.Status, "Scheduled", "4. wrong status for ftsStatus: %s" % ftsTransfer.Status )
    self.assertEqual( req.Status, "Scheduled", "4. wrong status for request: %s" % req.Status )

    # # reschedule
    ftsFile.Status = "Waiting"

    self.assertEqual( insertBefore.Status, "Done", "5. wrong status for insertBefore: %s" % insertBefore.Status )
    self.assertEqual( ftsTransfer.Status, "Waiting", "5. wrong status for ftsStatus: %s" % ftsTransfer.Status )
    self.assertEqual( req.Status, "Waiting", "5. wrong status for request: %s" % req.Status )

    # # fts done
    ftsFile.Status = "Done"

    self.assertEqual( insertBefore.Status, "Done", "5. wrong status for insertBefore: %s" % insertBefore.Status )
    self.assertEqual( ftsTransfer.Status, "Done", "5. wrong status for ftsStatus: %s" % ftsTransfer.Status )
    self.assertEqual( req.Status, "Done", "5. wrong status for request: %s" % req.Status )
开发者ID:JanEbbing,项目名称:DIRAC,代码行数:63,代码来源:RequestTests.py

示例3: test06StateMachine

# 需要导入模块: from DIRAC.RequestManagementSystem.Client.Request import Request [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.Request.Request import insertBefore [as 别名]
  def test06StateMachine( self ):
    """ state machine tests """
    r = Request( {"RequestName": "SMT"} )
    self.assertEqual( r.Status, "Waiting", "1. wrong status %s" % r.Status )

    r.addOperation( Operation( {"Status": "Queued"} ) )
    self.assertEqual( r.Status, "Waiting", "2. wrong status %s" % r.Status )

    r.addOperation( Operation( {"Status": "Queued"} ) )
    self.assertEqual( r.Status, "Waiting", "3. wrong status %s" % r.Status )

    r[0].Status = "Done"
    self.assertEqual( r.Status, "Waiting", "4. wrong status %s" % r.Status )

    r[1].Status = "Done"
    self.assertEqual( r.Status, "Done", "5. wrong status %s" % r.Status )

    r[0].Status = "Failed"
    self.assertEqual( r.Status, "Failed", "6. wrong status %s" % r.Status )

    r[0].Status = "Queued"
    self.assertEqual( r.Status, "Waiting", "7. wrong status %s" % r.Status )

    r.insertBefore( Operation( {"Status": "Queued"} ), r[0] )
    self.assertEqual( r.Status, "Waiting", "8. wrong status %s" % r.Status )

    r.insertBefore( Operation( {"Status": "Queued"} ), r[0] )
    self.assertEqual( r.Status, "Waiting", "9. wrong status %s" % r.Status )

    r.insertBefore( Operation( {"Status": "Scheduled"} ), r[0] )
    self.assertEqual( r.Status, "Scheduled", "10. wrong status %s" % r.Status )

    r.insertBefore( Operation( {"Status": "Queued" } ), r[0] )
    self.assertEqual( r.Status, "Waiting", "11. wrong status %s" % r.Status )

    r[0].Status = "Failed"
    self.assertEqual( r.Status, "Failed", "12. wrong status %s" % r.Status )

    r[0].Status = "Done"
    self.assertEqual( r.Status, "Scheduled", "13. wrong status %s" % r.Status )

    r[1].Status = "Failed"
    self.assertEqual( r.Status, "Failed", "14. wrong status %s" % r.Status )

    r[1].Status = "Done"
    self.assertEqual( r.Status, "Waiting", "15. wrong status %s" % r.Status )


    r[2].Status = "Scheduled"
    self.assertEqual( r.Status, "Scheduled", "16. wrong status %s" % r.Status )

    r[2].Status = "Queued"
    self.assertEqual( r.Status, "Waiting", "17. wrong status %s" % r.Status )

    r[2].Status = "Scheduled"
    self.assertEqual( r.Status, "Scheduled", "18. wrong status %s" % r.Status )

    r = Request()
    for i in range( 5 ):
      r.addOperation( Operation( {"Status": "Queued" } ) )

    r[0].Status = "Done"
    self.assertEqual( r.Status, "Waiting", "19. wrong status %s" % r.Status )

    r[1].Status = "Done"
    self.assertEqual( r.Status, "Waiting", "20. wrong status %s" % r.Status )

    r[2].Status = "Scheduled"
    self.assertEqual( r.Status, "Scheduled", "21. wrong status %s" % r.Status )

    r[2].Status = "Done"
    self.assertEqual( r.Status, "Waiting", "22. wrong status %s" % r.Status )
开发者ID:JanEbbing,项目名称:DIRAC,代码行数:74,代码来源:RequestTests.py

示例4: test04Operations

# 需要导入模块: from DIRAC.RequestManagementSystem.Client.Request import Request [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.Request.Request import insertBefore [as 别名]
  def test04Operations( self ):
    """ operations arithmetic and state machine """
    req = Request()
    self.assertEqual( len( req ), 0 )

    transfer = Operation()
    transfer.Type = "ReplicateAndRegister"
    transfer.addFile( File( { "LFN" : "/a/b/c", "Status" : "Waiting" } ) )

    getWaiting = req.getWaiting()
    self.assertEqual( getWaiting["OK"], True )
    self.assertEqual( getWaiting["Value"], None )

    req.addOperation( transfer )
    self.assertEqual( len( req ), 1 )
    self.assertEqual( transfer.Order, req.Order )
    self.assertEqual( transfer.Status, "Waiting" )

    getWaiting = req.getWaiting()
    self.assertEqual( getWaiting["OK"], True )
    self.assertEqual( getWaiting["Value"], transfer )

    removal = Operation( { "Type" : "RemoveFile" } )
    removal.addFile( File( { "LFN" : "/a/b/c", "Status" : "Waiting" } ) )

    req.insertBefore( removal, transfer )

    getWaiting = req.getWaiting()
    self.assertEqual( getWaiting["OK"], True )
    self.assertEqual( getWaiting["Value"], removal )

    self.assertEqual( len( req ), 2 )
    self.assertEqual( [ op.Status for op in req ], ["Waiting", "Queued"] )
    self.assertEqual( req.subStatusList() , ["Waiting", "Queued"] )


    self.assertEqual( removal.Order, 0 )
    self.assertEqual( removal.Order, req.Order )

    self.assertEqual( transfer.Order, 1 )

    self.assertEqual( removal.Status, "Waiting" )
    self.assertEqual( transfer.Status, "Queued" )

    for subFile in removal:
      subFile.Status = "Done"
    removal.Status = "Done"

    self.assertEqual( removal.Status, "Done" )

    self.assertEqual( transfer.Status, "Waiting" )
    self.assertEqual( transfer.Order, req.Order )

    # # len, looping
    self.assertEqual( len( req ), 2 )
    self.assertEqual( [ op.Status for op in req ], ["Done", "Waiting"] )
    self.assertEqual( req.subStatusList() , ["Done", "Waiting"] )

    digest = req.toJSON()
    self.assertEqual( digest["OK"], True )

    getWaiting = req.getWaiting()
    self.assertEqual( getWaiting["OK"], True )
    self.assertEqual( getWaiting["Value"], transfer )
开发者ID:JanEbbing,项目名称:DIRAC,代码行数:66,代码来源:RequestTests.py


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