Occasionally the 4od site will send a gzip encoded page or will timeout.
The following change will try the site 3 times, add a 20 second timeout and
handle the gzip issue:
file: geturllib.py
replace _GetURL_NoCache with:
#==============================================================================
def _GetURL_NoCache( url ):
import urllib2,time,socket,gzip,StringIO
socket.setdefaulttimeout(20)
x=''
try:
x = urllib2.urlopen(url)
except ( urllib2.HTTPError, urllib2.URLError ) as err:
try:
x = urllib2.urlopen(url)
except ( urllib2.HTTPError, urllib2.URLError ) as err:
try:
x = urllib2.urlopen(url)
except ( urllib2.HTTPError, urllib2.URLError ) as err:
print err.reason
#x = urllib2.urlopen(url)
try:
if x.info()['content-encoding'] == 'gzip':
gzipper = gzip.GzipFile(fileobj=StringIO.StringIO(x.read()))
x=gzipper.read()
else:
x=x.read()
except KeyError:
x=x.read()
return x
#==============================================================================
Original issue reported on code.google.com by j...@vetsurgeon.org.uk on 10 May 2012 at 8:10
Original issue reported on code.google.com by
j...@vetsurgeon.org.uk
on 10 May 2012 at 8:10