Skip to content

Commit

Permalink
Merge pull request #25 from d1b/master
Browse files Browse the repository at this point in the history
Please pull!
  • Loading branch information
ioerror committed Dec 19, 2011
2 parents e4c6655 + ea48203 commit 819b0f0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions blockfinder
Expand Up @@ -62,7 +62,8 @@ def fetch(url, useragent):
fetcher = urllib2.urlopen(req)
length_header = fetcher.headers.get("content-length")
if length_header == None:
raise Exception("Missing content-length header in reply from server.")
""" The server did not provide a content-length header. """
length_header = -1
length = int(length_header)
print "Fetching ", str (round(float(length/1024),2)) , " kilobytes"
ret = ""
Expand All @@ -71,12 +72,12 @@ def fetch(url, useragent):
t_delta = time.time() - t_start
if t_delta == 0:
t_delta = 1
update_progress_bar(
float(len(ret)) / length,
"%.2f K/s" % (len(ret) / 1024 / t_delta) )
if length_header != -1:
update_progress_bar( float(len(ret)) / length,
"%.2f K/s" % (len(ret) / 1024 / t_delta) )
tmp = fetcher.read(1024)
if len(tmp) == 0:
if len(ret) != length:
if len(ret) != length and length_header != -1:
raise Exception("Expected %s bytes, only received %s" % (
len(ret), length ))
print ""
Expand Down

0 comments on commit 819b0f0

Please sign in to comment.