parameters: (url, output_file)
docstring: Download url into output_file.
docstring_summary: Download url into output_file.
docstring_tokens: Download url into output_file .
function: def DownloadUrl(url, output_file):
    """Download url into output_file."""
    CHUNK_SIZE = 4096
    TOTAL_DOTS = 10
    num_retries = 3
    retry_wait_s = 5  # Doubled at each retry.
  
    while True:
      try:
        sys.stdout.write('Downloading %s ' % url)
        sys.stdout.flush()
        response = urllib2.urlopen(url)
        total_size = int(response.info().getheader('Content-Length').strip())
        bytes_done = 0
        dots_printed = 0
        while True:
          chunk = response.read(CHUNK_SIZE)
          if not chunk:
            break
          output_file.write(chunk)
          bytes_done += len(chunk)
          num_dots = TOTAL_DOTS * bytes_done / total_size
          sys.stdout.write('.' * (num_dots - dots_printed))
          sys.stdout.flush()
          dots_printed = num_dots
        if bytes_done != total_size:
          raise urllib2.URLError("only got %d of %d bytes" %
                                 (bytes_done, total_size))
        print ' Done.'
        return
      except urllib2.URLError as e:
        sys.stdout.write('\n')
        print e
        if num_retries == 0 or isinstance(e, urllib2.HTTPError) and e.code == 404:
          raise e
        num_retries -= 1
        print 'Retrying in %d s ...' % retry_wait_s
        time.sleep(retry_wait_s)
        retry_wait_s *= 2
function_tokens: def DownloadUrl ( url , output_file ) : CHUNK_SIZE = 4096 TOTAL_DOTS = 10 num_retries = 3 retry_wait_s = 5 # Doubled at each retry. while True : try : sys . stdout . write ( 'Downloading %s ' % url ) sys . stdout . flush ( ) response = urllib2 . urlopen ( url ) total_size = int ( response . info ( ) . getheader ( 'Content-Length' ) . strip ( ) ) bytes_done = 0 dots_printed = 0 while True : chunk = response . read ( CHUNK_SIZE ) if not chunk : break output_file . write ( chunk ) bytes_done += len ( chunk ) num_dots = TOTAL_DOTS * bytes_done / total_size sys . stdout . write ( '.' * ( num_dots - dots_printed ) ) sys . stdout . flush ( ) dots_printed = num_dots if bytes_done != total_size : raise urllib2 . URLError ( "only got %d of %d bytes" % ( bytes_done , total_size ) ) print ' Done.' return except urllib2 . URLError as e : sys . stdout . write ( '\n' ) print e if num_retries == 0 or isinstance ( e , urllib2 . HTTPError ) and e . code == 404 : raise e num_retries -= 1 print 'Retrying in %d s ...' % retry_wait_s time . sleep ( retry_wait_s ) retry_wait_s *= 2