[issue16409] urlretrieve regression: first call returns block size as 0

akira report at bugs.python.org
Mon Nov 5 16:01:36 CET 2012


akira added the comment:

The summary assumes that issue 10050 is valid i.e., urlretrieve is
reimplemented using new urlopen and 2.x FancyURLopener is deprecated.

It might not be so [1]. In this case the summary is incorrect.

Old implementation is available as:

  opener = FancyURLopener()
  urlretrieve = opener.retrieve

btw, the new implementation doesn't prevent you to estimate the 
progress:

  def make_reporthook():
      read = 0  # number of bytes read so far
      def reporthook(blocknum, blocksize, totalsize):
          nonlocal read
          read += blocksize
          if totalsize > 0:
              percent = read * 1e2 / totalsize
              print("%5.1f%% %*d / %d" % (
                      percent, len(str(totalsize)), read, totalsize))
          else:
              print("read %d" % (read,))
      return reporthook


[1]: http://mail.python.org/pipermail/python-dev/2011-March/109450.html

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16409>
_______________________________________


More information about the Python-bugs-list mailing list