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


Python DataManager.getReplica方法代码示例

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


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

示例1: SETest

# 需要导入模块: from DIRAC.DataManagementSystem.Client.DataManager import DataManager [as 别名]
# 或者: from DIRAC.DataManagementSystem.Client.DataManager.DataManager import getReplica [as 别名]
class SETest( TestBase ):
  """
    SETest is used to test the availability of SE.
  """
    
  def __init__( self, args = None, apis = None ):
    super( SETest, self ).__init__( args, apis )
    
    self.__lfnPath = '/bes/user/z/zhaoxh/'
    self.__testFile = 'test.dat'
    self.__localPath = '/tmp/'
    
    if 'DataManager' in self.apis:
      self.dm = self.apis[ 'DataManager' ]
    else:
      self.dm = DataManager()
    
    
  def doTest( self, elementDict ):
    """
      Test upload and download for specified SE.
    """
    
    elementName = elementDict[ 'ElementName' ]

    testFilePath = self.__localPath + self.__testFile
    if not os.path.exists( testFilePath ) or not os.path.isfile( testFilePath ):
      f = open( testFilePath, 'w' )
      f.write( 'hello' )
      f.close()
        
    status = 'OK'
    log = ''
    lfnPath = self.__lfnPath + elementName + '-' + self.__testFile
    submissionTime = datetime.utcnow().replace( microsecond = 0 )
    
    LOCK.acquire()
    start = time.time()
    result = self.dm.putAndRegister( lfnPath, testFilePath, elementName )
    uploadTime = time.time() - start
    if result[ 'OK' ]:
      log += 'Succeed to upload file to SE %s.\n' % elementName
      log += 'Upload Time : %ss\n' % uploadTime
      
      start = time.time()
      result = self.dm.getReplica( lfnPath, elementName, self.__localPath )
      downloadTime = time.time() - start
      if result[ 'OK' ]:
        log += 'Succeed to download file from SE %s.\n' % elementName
        log += 'Download Time : %ss\n' % downloadTime
      else:
        status = 'Bad'
        log += 'Failed to download file from SE %s : %s\n' % ( elementName, result[ 'Message' ] )
      
      result = self.dm.removeFile( lfnPath )
      if result[ 'OK' ]:
        log += 'Succeed to delete file from SE %s.\n' % elementName
      else:
        log += 'Faile to delete file from SE %s : %s\n' % ( elementName, result[ 'Message' ] )
        
    else:
      status = 'Bad'
      log += 'Failed to upload file to SE %s : %s\n' % ( elementName, result[ 'Message' ] )
    LOCK.release()
      
    completionTime = datetime.utcnow().replace( microsecond = 0 )
    applicationTime = ( completionTime - submissionTime ).total_seconds()
    
    result = { 'Result' : { 'Status' : status,
                           'Log' : log,
                           'SubmissionTime' : submissionTime,
                           'CompletionTime' : completionTime,
                           'ApplicationTime' : applicationTime },
              'Finish' : True }

    localFile = self.__localPath + elementName +'-' + self.__testFile
    if os.path.exists( localFile ) and os.path.isfile( localFile ):
      os.remove( localFile )
      
    return S_OK( result )
开发者ID:cj501885963,项目名称:BES-RSS,代码行数:82,代码来源:SETest.py

示例2: DataManager

# 需要导入模块: from DIRAC.DataManagementSystem.Client.DataManager import DataManager [as 别名]
# 或者: from DIRAC.DataManagementSystem.Client.DataManager.DataManager import getReplica [as 别名]
exit_code = 0
log = ''

dm = DataManager()

start = time.time()
result = dm.removeFile( lfn )
result = dm.putAndRegister( lfn, pfn, se )
uploadTime = time.time() - start
if result[ 'OK' ]:
  log += 'Succeed to upload file to SE %s.\n' % se
  log += 'Upload Time : %ss\n' % uploadTime

  start = time.time()
  result = dm.getReplica( lfn, se, tempfile.gettempdir() )
  downloadTime = time.time() - start
  if result[ 'OK' ]:
    log += 'Succeed to download file from SE %s.\n' % se
    log += 'Download Time : %ss\n' % downloadTime
  else:
    exit_code = 1
    log += 'Failed to download file from SE %s : %s\n' % ( se, result[ 'Message' ] )

  result = dm.removeFile( lfn )
  if result[ 'OK' ]:
    log += 'Succeed to delete file from SE %s.\n' % se
  else:
    log += 'Faile to delete file from SE %s : %s\n' % ( se, result[ 'Message' ] )

else:
开发者ID:besdiracgrid,项目名称:BESDIRAC,代码行数:32,代码来源:se_test.py


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