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


Python File.Checksum方法代码示例

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


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

示例1: buildRequest

# 需要导入模块: from DIRAC.RequestManagementSystem.Client.File import File [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.File.File import Checksum [as 别名]
  def buildRequest( self, owner, group, sourceSE, targetSE1, targetSE2 ):

    files = self.files( owner, group )

    putAndRegister = Operation()
    putAndRegister.Type = "PutAndRegister"
    putAndRegister.TargetSE = sourceSE
    for fname, lfn, size, checksum, guid in files:
      putFile = File()
      putFile.LFN = lfn
      putFile.PFN = fname
      putFile.Checksum = checksum
      putFile.ChecksumType = "adler32"
      putFile.Size = size
      putFile.GUID = guid
      putAndRegister.addFile( putFile )

    replicateAndRegister = Operation()
    replicateAndRegister.Type = "ReplicateAndRegister"
    replicateAndRegister.TargetSE = "%s,%s" % ( targetSE1, targetSE2 )
    for fname, lfn, size, checksum, guid in files:
      repFile = File()
      repFile.LFN = lfn
      repFile.Size = size
      repFile.Checksum = checksum
      repFile.ChecksumType = "adler32"
      replicateAndRegister.addFile( repFile )

    removeReplica = Operation()
    removeReplica.Type = "RemoveReplica"
    removeReplica.TargetSE = sourceSE
    for fname, lfn, size, checksum, guid in files:
      removeReplica.addFile( File( {"LFN": lfn } ) )

    removeFile = Operation()
    removeFile.Type = "RemoveFile"
    for fname, lfn, size, checksum, guid in files:
      removeFile.addFile( File( {"LFN": lfn } ) )

    removeFileInit = Operation()
    removeFileInit.Type = "RemoveFile"
    for fname, lfn, size, checksum, guid in files:
      removeFileInit.addFile( File( {"LFN": lfn } ) )

    req = Request()
    req.addOperation( removeFileInit )
    req.addOperation( putAndRegister )
    req.addOperation( replicateAndRegister )
    req.addOperation( removeReplica )
    req.addOperation( removeFile )
    return req
开发者ID:arrabito,项目名称:TestDIRAC,代码行数:53,代码来源:IntegrationFCT.py

示例2: __setFileReplicationRequest

# 需要导入模块: from DIRAC.RequestManagementSystem.Client.File import File [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.File.File import Checksum [as 别名]
  def __setFileReplicationRequest( self, lfn, targetSE, fileMetaDict, sourceSE = '' ):
    """ Sets a registration request.
    """
    self.log.info( 'Setting replication request for %s to %s' % ( lfn, targetSE ) )

    transfer = Operation()
    transfer.Type = "ReplicateAndRegister"
    transfer.TargetSE = targetSE
    if sourceSE:
      transfer.SourceSE = sourceSE

    trFile = File()
    trFile.LFN = lfn

    cksm = fileMetaDict.get( "Checksum", None )
    cksmType = fileMetaDict.get( "ChecksumType", None )
    if cksm and cksmType:
      trFile.Checksum = cksm
      trFile.ChecksumType = cksmType
    size = fileMetaDict.get( "Size", 0 )
    if size:
      trFile.Size = size
    guid = fileMetaDict.get( "GUID", "" )
    if guid:
      trFile.GUID = guid

    transfer.addFile( trFile )

    self.request.addOperation( transfer )

    return S_OK()
开发者ID:graciani,项目名称:DIRAC,代码行数:33,代码来源:FailoverTransfer.py

示例3: __setRegistrationRequest

# 需要导入模块: from DIRAC.RequestManagementSystem.Client.File import File [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.File.File import Checksum [as 别名]
  def __setRegistrationRequest( self, lfn, targetSE, fileDict, catalog ):
    """ Sets a registration request

    :param str lfn: LFN
    :param list se: list of SE
    :param list catalog: list of catalogs to use
    :param dict fileDict: file metadata
    """
    self.log.info( 'Setting registration request for %s at %s.' % ( lfn, targetSE ) )

    for cat in catalog:

      register = Operation()
      register.Type = "RegisterFile"
      register.Catalog = cat
      register.TargetSE = targetSE

      regFile = File()
      regFile.LFN = lfn
      regFile.Checksum = fileDict.get( "Checksum", "" )
      regFile.ChecksumType = fileDict.get( "ChecksumType", "" )
      regFile.Size = fileDict.get( "Size", 0 )
      regFile.GUID = fileDict.get( "GUID", "" )

      se = StorageElement( targetSE )
      pfn = se.getPfnForLfn( lfn )
      if not pfn["OK"]:
        self.log.error( "unable to get PFN for LFN: %s" % pfn["Message"] )
        return pfn
      regFile.PFN = pfn["Value"]

      register.addFile( regFile )
      self.request.addOperation( register )

    return S_OK()
开发者ID:msapunov,项目名称:DIRAC,代码行数:37,代码来源:FailoverTransfer.py

示例4: test02props

# 需要导入模块: from DIRAC.RequestManagementSystem.Client.File import File [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.File.File import Checksum [as 别名]
  def test02props( self ):
    """ test props and attributes  """
    theFile = File()

    # valid props
    theFile.FileID = 1
    self.assertEqual( theFile.FileID, 1 )
    theFile.Status = "Done"
    self.assertEqual( theFile.Status, "Done" )
    theFile.LFN = "/some/path/somewhere"
    self.assertEqual( theFile.LFN, "/some/path/somewhere" )
    theFile.PFN = "/some/path/somewhere"
    self.assertEqual( theFile.PFN, "/some/path/somewhere" )
    theFile.Attempt = 1
    self.assertEqual( theFile.Attempt, 1 )
    theFile.Size = 1
    self.assertEqual( theFile.Size, 1 )
    theFile.GUID = "2bbabe80-e2f1-11e1-9b23-0800200c9a66"
    self.assertEqual( theFile.GUID, "2bbabe80-e2f1-11e1-9b23-0800200c9a66" )
    theFile.ChecksumType = "adler32"
    self.assertEqual( theFile.ChecksumType, "ADLER32" )
    theFile.Checksum = "123456"
    self.assertEqual( theFile.Checksum, "123456" )

    # #
    theFile.Checksum = None
    theFile.ChecksumType = None
    self.assertEqual( theFile.Checksum, "" )
    self.assertEqual( theFile.ChecksumType, "" )

    # # invalid props

    # FileID
    try:
      theFile.FileID = "foo"
    except Exception, error:
      self.assertEqual( isinstance( error, ValueError ), True )
开发者ID:sbel,项目名称:bes3-jinr,代码行数:39,代码来源:FileTests.py

示例5: getRegisterOperation

# 需要导入模块: from DIRAC.RequestManagementSystem.Client.File import File [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.File.File import Checksum [as 别名]
  def getRegisterOperation( self, opFile, targetSE ):
    """ add RegisterReplica operation for file

    :param File opFile: operation file
    :param str targetSE: target SE
    """
    # # add RegisterReplica operation
    registerOperation = Operation()
    registerOperation.Type = "RegisterFile"
    registerOperation.TargetSE = targetSE

    registerFile = File()
    registerFile.LFN = opFile.LFN
    registerFile.PFN = opFile.PFN
    registerFile.GUID = opFile.GUID
    registerFile.Checksum = opFile.Checksum
    registerFile.ChecksumType = opFile.ChecksumType
    registerFile.Size = opFile.Size

    registerOperation.addFile( registerFile )
    return registerOperation
开发者ID:afalabel,项目名称:DIRAC,代码行数:23,代码来源:DMSRequestOperationsBase.py

示例6: addRegisterReplica

# 需要导入模块: from DIRAC.RequestManagementSystem.Client.File import File [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.File.File import Checksum [as 别名]
  def addRegisterReplica( self, opFile, targetSE ):
    """ add RegisterReplica operation for file

    :param File opFile: operation file
    :param str targetSE: target SE
    """
    # # add RegisterReplica operation
    registerOperation = Operation()
    registerOperation.Type = "RegisterFile"
    registerOperation.TargetSE = targetSE

    registerFile = File()
    registerFile.LFN = opFile.LFN
    registerFile.PFN = opFile.PFN
    registerFile.GUID = opFile.GUID
    registerFile.Checksum = opFile.Checksum
    registerFile.ChecksumType = opFile.ChecksumType
    registerFile.Size = opFile.Size

    registerOperation.addFile( registerFile )
    self.request.insertAfter( registerOperation, self.operation )
    return S_OK()
开发者ID:IgorPelevanyuk,项目名称:DIRAC,代码行数:24,代码来源:ReplicateAndRegister.py

示例7: _setRegistrationRequest

# 需要导入模块: from DIRAC.RequestManagementSystem.Client.File import File [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.File.File import Checksum [as 别名]
  def _setRegistrationRequest( self, lfn, targetSE, fileDict, catalog ):
    """ Sets a registration request

    :param str lfn: LFN
    :param list se: list of SE (or just string)
    :param list catalog: list (or string) of catalogs to use
    :param dict fileDict: file metadata
    """
    self.log.info( 'Setting registration request for %s at %s.' % ( lfn, targetSE ) )

    if not isinstance( catalog, list ):
      catalog = [catalog]

    for cat in catalog:

      register = Operation()
      register.Type = "RegisterFile"
      register.Catalog = cat
      register.TargetSE = targetSE

      regFile = File()
      regFile.LFN = lfn
      regFile.Checksum = fileDict.get( "Checksum", "" )
      regFile.ChecksumType = fileDict.get( "ChecksumType", self.defaultChecksumType )
      regFile.Size = fileDict.get( "Size", 0 )
      regFile.GUID = fileDict.get( "GUID", "" )

      se = StorageElement( targetSE )
      pfn = se.getURL( lfn, self.registrationProtocols )
      if not pfn["OK"] or lfn not in pfn["Value"]['Successful']:
        self.log.error( "Unable to get PFN for LFN", "%s" % pfn.get( 'Message', pfn.get( 'Value', {} ).get( 'Failed', {} ).get( lfn ) ) )
        return pfn
      regFile.PFN = pfn["Value"]['Successful'][lfn]

      register.addFile( regFile )
      self.request.addOperation( register )

    return S_OK()
开发者ID:DIRACGrid-test,项目名称:DIRAC,代码行数:40,代码来源:FailoverTransfer.py

示例8: File

# 需要导入模块: from DIRAC.RequestManagementSystem.Client.File import File [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.File.File import Checksum [as 别名]
  res = fc.getFileMetadata( lfnList )
  if not res['OK']:
    print "Can't get file metadata: %s" % res['Message']
    DIRAC.exit( 1 )
  if res['Value']['Failed']:
    print "Could not get the file metadata of the following, so skipping them:"
    for fFile in res['Value']['Failed']:
      print fFile

  lfnMetadata = res['Value']['Successful']

  for lfn in lfnMetadata:
    rarFile = File()
    rarFile.LFN = lfn
    rarFile.Size = lfnMetadata[lfn]['Size']
    rarFile.Checksum = lfnMetadata[lfn]['Checksum']
    rarFile.GUID = lfnMetadata[lfn]['GUID']
    rarFile.ChecksumType = 'ADLER32'
    replicateAndRegister.addFile( rarFile )

  oRequest.addOperation( replicateAndRegister )
  isValid = RequestValidator().validate( oRequest )
  if not isValid['OK']:
    print "Request is not valid: ", isValid['Message']
    DIRAC.exit( 1 )

  result = reqClient.putRequest( oRequest )
  if result['OK']:
    print "Request %d submitted successfully" % result['Value']
  else:
    print "Failed to submit Request: ", result['Message']
开发者ID:corionma,项目名称:DIRAC,代码行数:33,代码来源:dirac-dms-create-replication-request.py

示例9: Operation

# 需要导入模块: from DIRAC.RequestManagementSystem.Client.File import File [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.File.File import Checksum [as 别名]
    replicateAndRegister = Operation()
    replicateAndRegister.Type = "ReplicateAndRegister"
    replicateAndRegister.TargetSE = ",".join( targetSEs )
    if catalog is not None:
      replicateAndRegister.Catalog = catalog

    for lfn in lfnChunk:
      metaDict = metaDatas["Successful"][lfn]
      opFile = File()
      opFile.LFN = lfn
      opFile.Size = metaDict["Size"]

      if "Checksum" in metaDict:
        # # should check checksum type, now assuming Adler32 (metaDict["ChecksumType"] = 'AD'
        opFile.Checksum = metaDict["Checksum"]
        opFile.ChecksumType = "ADLER32"
      replicateAndRegister.addFile( opFile )

    request.addOperation( replicateAndRegister )

    putRequest = reqClient.putRequest( request )
    if not putRequest["OK"]:
      gLogger.error( "unable to put request '%s': %s" % ( request.RequestName, putRequest["Message"] ) )
      error = -1
      continue
    requestIDs.append( str( putRequest["Value"] ) )
    if not multiRequests:
      gLogger.always( "Request '%s' has been put to ReqDB for execution." % request.RequestName )

  if multiRequests:
开发者ID:marianne013,项目名称:DIRAC,代码行数:32,代码来源:dirac-dms-replicate-and-register-request.py

示例10: test05FTS

# 需要导入模块: from DIRAC.RequestManagementSystem.Client.File import File [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.File.File import Checksum [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

示例11: fileAdler

# 需要导入模块: from DIRAC.RequestManagementSystem.Client.File import File [as 别名]
# 或者: from DIRAC.RequestManagementSystem.Client.File.File import Checksum [as 别名]
  PFN = os.path.abspath( PFN )
  size = os.path.getsize( PFN )
  adler32 = fileAdler( PFN )

  request = Request()
  request.RequestName = requestName

  putAndRegister = Operation()
  putAndRegister.Type = "PutAndRegister"
  putAndRegister.TargetSE = targetSE
  opFile = File()
  opFile.LFN = LFN
  opFile.PFN = PFN
  opFile.Size = size
  opFile.Checksum = adler32
  opFile.ChecksumType = "ADLER32"
  putAndRegister.addFile( opFile )
  request.addOperation( putAndRegister )
  reqClient = ReqClient()
  putRequest = reqClient.putRequest( request )
  if not putRequest["OK"]:
    gLogger.error( "unable to put request '%s': %s" % ( requestName, putRequest["Message"] ) )
    DIRAC.exit( -1 )

  gLogger.always( "Request '%s' has been put to ReqDB for execution." % requestName )
  gLogger.always( "You can monitor its status using command: 'dirac-rms-show-request %s'" % requestName )
  DIRAC.exit( 0 )


开发者ID:DIRACGrid-test,项目名称:DIRAC,代码行数:29,代码来源:dirac-dms-put-and-register-request.py


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