#NEWLINE# def get_file( self , fp , headers = None , cb = None , num_cb = 10 , torrent = False , version_id = None , override_num_retries = None , response_headers = None , callback = None ) : #NEWLINE# #INDENT# '\n        Retrieves a file from an S3 Key\n\n        :type fp: file\n        :param fp: File pointer to put the data into\n\n        :type headers: string\n        :param: headers to send when retrieving the files\n\n        :type cb: function\n        :param cb: a callback function that will be called to report\n                   progress on the upload.  The callback should accept\n                   two integer parameters, the first representing the\n                   number of bytes that have been successfully\n                   transmitted to S3 and the second representing the\n                   size of the to be transmitted object.\n\n        :type cb: int\n        :param num_cb: (optional) If a callback is specified with\n                       the cb parameter this parameter determines the\n                       granularity of the callback by defining\n                       the maximum number of times the callback will\n                       be called during the file transfer.\n\n        :type torrent: bool\n        :param torrent: Flag for whether to get a torrent for the file\n\n        :type override_num_retries: int\n        :param override_num_retries: If not None will override configured\n                                     num_retries parameter for underlying GET.\n\n        :type response_headers: dict\n        :param response_headers: A dictionary containing HTTP headers/values\n                                 that will override any headers associated with\n                                 the stored object in the response.\n                                 See http://goo.gl/EWOPb for details.\n        ' #NEWLINE# if cb : #NEWLINE# #INDENT# if ( num_cb > 2 ) : #NEWLINE# #INDENT# cb_count = ( ( self . size / self . BufferSize ) / ( num_cb - 2 ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( num_cb < 0 ) : #NEWLINE# #INDENT# cb_count = ( - 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# cb_count = 0 #NEWLINE# #UNINDENT# #UNINDENT# i = total_bytes = 0 #NEWLINE# cb ( total_bytes , self . size ) #NEWLINE# #UNINDENT# save_debug = self . bucket . connection . debug #NEWLINE# if ( self . bucket . connection . debug == 1 ) : #NEWLINE# #INDENT# self . bucket . connection . debug = 0 #NEWLINE# #UNINDENT# query_args = [ ] #NEWLINE# if torrent : #NEWLINE# #INDENT# query_args . append ( 'torrent' ) #NEWLINE# #UNINDENT# if ( num_cb is None ) : #NEWLINE# #INDENT# version_id = self . version_id #NEWLINE# #UNINDENT# if version_id : #NEWLINE# #INDENT# query_args . append ( ( 'versionId=%s' % version_id ) ) #NEWLINE# #UNINDENT# if response_headers : #NEWLINE# #INDENT# for key in response_headers : #NEWLINE# #INDENT# query_args . append ( ( '%s=%s' % ( key , response_headers [ key ] ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# query_args = '&' . join ( query_args ) #NEWLINE# def file_got( response ) : #NEWLINE# #INDENT# body = self . resp . read ( ) #NEWLINE# fp . write ( body ) #NEWLINE# if cb : #NEWLINE# #INDENT# cb ( total_bytes , self . size ) #NEWLINE# #UNINDENT# self . close ( ) #NEWLINE# self . bucket . connection . debug = save_debug #NEWLINE# if callable ( callback ) : #NEWLINE# #INDENT# callback ( response ) #NEWLINE# #UNINDENT# #UNINDENT# self . open ( 'r' , headers , query_args = query_args , override_num_retries = override_num_retries , callback = file_got )