Logo Search packages:      
Sourcecode: s3ql version File versions  Download package

def s3ql::backends::boto::s3::key::Key::get_file (   self,
  fp,
  headers = None,
  cb = None,
  num_cb = 10,
  torrent = False,
  version_id = None 
)
Retrieves a file from an S3 Key

:type fp: file
:param fp: File pointer to put the data into

:type headers: string
:param: headers to send when retrieving the files

:type cb: function
:param cb: (optional) a callback function that will be called to report
     progress on the download.  The callback should accept two integer
     parameters, the first representing the number of bytes that have
     been successfully transmitted from S3 and the second representing
     the total number of bytes that need to be transmitted.

    
:type cb: int
:param num_cb: (optional) If a callback is specified with the cb parameter
     this parameter determines the granularity of the callback by defining
     the maximum number of times the callback will be called during the file transfer.  
     
:type torrent: bool
:param torrent: Flag for whether to get a torrent for the file

Definition at line 662 of file key.py.

                                                :
        """
        Retrieves a file from an S3 Key
        
        :type fp: file
        :param fp: File pointer to put the data into
        
        :type headers: string
        :param: headers to send when retrieving the files
        
        :type cb: function
        :param cb: (optional) a callback function that will be called to report
             progress on the download.  The callback should accept two integer
             parameters, the first representing the number of bytes that have
             been successfully transmitted from S3 and the second representing
             the total number of bytes that need to be transmitted.
        
                    
        :type cb: int
        :param num_cb: (optional) If a callback is specified with the cb parameter
             this parameter determines the granularity of the callback by defining
             the maximum number of times the callback will be called during the file transfer.  
             
        :type torrent: bool
        :param torrent: Flag for whether to get a torrent for the file
        """
        if cb:
            if num_cb > 2:
                cb_count = self.size / self.BufferSize / (num_cb - 2)
            else:
                cb_count = 0
            i = total_bytes = 0
            cb(total_bytes, self.size)
        save_debug = self.bucket.connection.debug
        if self.bucket.connection.debug == 1:
            self.bucket.connection.debug = 0

        query_args = ''
        if torrent:
            query_args = 'torrent'
        elif version_id:
            query_args = 'versionId=%s' % version_id
        self.open('r', headers, query_args=query_args)
        for bytes in self:
            fp.write(bytes)
            if cb:
                total_bytes += len(bytes)
                i += 1
                if i == cb_count:
                    cb(total_bytes, self.size)
                    i = 0
        if cb:
            cb(total_bytes, self.size)
        self.close()
        self.bucket.connection.debug = save_debug


Generated by  Doxygen 1.6.0   Back to index