[Patches] [ python-Patches-849407 ] urllib reporthook could be more
informative
SourceForge.net
noreply at sourceforge.net
Tue Nov 25 22:41:59 EST 2003
Patches item #849407, was opened at 2003-11-25 19:41
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=849407&group_id=5470
Category: Library (Lib)
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Allan B. Wilson (allanbwilson)
Assigned to: Nobody/Anonymous (nobody)
Summary: urllib reporthook could be more informative
Initial Comment:
A reporthook in urllib.urlretrieve() (in 2.3.2) is
given the max number of characters accepted ("bs") per
.read() as its second argument. It would be more
helpful to receive the number of characters actually
retrieved in the most recent block.
While perhaps this would break some existing code
(though I can't imagine how), the minor patches below
will allow giving progess updates, etc. that are accurate.
Thanks
Allan Wilson
------------
*** urllib.py.old Tue Nov 25 17:42:55 2003
--- urllib.py Tue Nov 25 18:00:50 2003
***************
*** 236,248 ****
reporthook(0, bs, size)
block = fp.read(bs)
if reporthook:
! reporthook(1, bs, size)
while block:
tfp.write(block)
block = fp.read(bs)
blocknum = blocknum + 1
if reporthook:
! reporthook(blocknum, bs, size)
fp.close()
tfp.close()
del fp
--- 236,248 ----
reporthook(0, bs, size)
block = fp.read(bs)
if reporthook:
! reporthook(1, len(block), size)
while block:
tfp.write(block)
block = fp.read(bs)
blocknum = blocknum + 1
if reporthook:
! reporthook(blocknum, len(block), size)
fp.close()
tfp.close()
del fp
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=849407&group_id=5470
More information about the Patches
mailing list