def _chunk_read(response, local_file, chunk_size=65536, initial_size=0):
 bytes_so_far = initial_size
 total_size = int(response.headers['Content-Length'].strip())
 total_size += initial_size
 progress = ProgressBar(total_size, initial_value=bytes_so_far, max_chars=40, spinner=True, mesg='downloading')
 while True:
  chunk = response.read(chunk_size)
  bytes_so_far += len(chunk)
  if (not chunk):
   sys.stderr.write('\n')
   break
  _chunk_write(chunk, local_file, progress)

def _chunk_read ( response , local_file , chunk_size = 65536 , initial_size = 0 ) : bytes_so_far = initial_size total_size = int ( response . headers [ 'Content-Length' ] . strip ( ) ) total_size += initial_size progress = ProgressBar ( total_size , initial_value = bytes_so_far , max_chars = 40 , spinner = True , mesg = 'downloading' ) while True : chunk = response . read ( chunk_size ) bytes_so_far += len ( chunk ) if ( not chunk ) : sys . stderr . write ( '\n' ) break _chunk_write ( chunk , local_file , progress )
download a file chunk by chunk and show advancement can also be used when resuming downloads over http .