예제 #1
0
    def receiveBulk(self, destDir, bulkId, token="", compress=True):
        """
    Receive a bulk of files from server

    @type destDir : list of ( string / file descriptor / file object )
    @param destDir : Files to receive from server
    @type bulkId : any
    @param bulkId : Identification of the files being received
    @type token : string
    @param token : Token for the bulk
    @type compress : boolean
    @param compress : Enable compression for the bulk. By default its True
    @return : S_OK/S_ERROR
    """
        if not os.path.isdir(destDir):
            return S_ERROR("%s is not a directory for bulk receival" % destDir)
        if compress:
            bulkId = "%s.tar.bz2" % bulkId
        else:
            bulkId = "%s.tar" % bulkId
        try:
            retVal = self._sendTransferHeader("BulkToClient", (bulkId, token))
            if not retVal['OK']:
                return retVal
            transport = retVal['Value']
            fileHelper = FileHelper(transport)
            retVal = fileHelper.networkToBulk(destDir, compress)
            if not retVal['OK']:
                return retVal
            retVal = transport.receiveData()
            self._disconnect()
            return retVal
        finally:
            self._disconnect()
예제 #2
0
파일: TransferClient.py 프로젝트: bmb/DIRAC
  def receiveBulk( self, destDir, bulkId, token = "", compress = True ):
    """
    Receive a bulk of files from server

    @type destDir : list of ( string / file descriptor / file object )
    @param destDir : Files to receive from server
    @type bulkId : any
    @param bulkId : Identification of the files being received
    @type token : string
    @param token : Token for the bulk
    @type compress : boolean
    @param compress : Enable compression for the bulk. By default its True
    @return : S_OK/S_ERROR
    """
    if not os.path.isdir( destDir ):
      return S_ERROR( "%s is not a directory for bulk receival" % destDir )
    if compress:
      bulkId = "%s.tar.bz2" % bulkId
    else:
      bulkId = "%s.tar" % bulkId
    retVal = self._sendTransferHeader( "BulkToClient", ( bulkId, token ) )
    if not retVal[ 'OK' ]:
      return retVal
    trid, transport = retVal[ 'Value' ]
    try:
      fileHelper = FileHelper( transport )
      retVal = fileHelper.networkToBulk( destDir, compress )
      if not retVal[ 'OK' ]:
        return retVal
      retVal = transport.receiveData()
      return retVal
    finally: