Skip to content

Commit

Permalink
urlretrieve: Expand to cope with errors
Browse files Browse the repository at this point in the history
  • Loading branch information
palfrey committed Jan 25, 2011
1 parent 144e808 commit a287732
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions _Cache.py
Expand Up @@ -179,8 +179,9 @@ def delete(self, obj): # removes from cache
raise Exception, "We never got that URL! ("+obj.url+")"

def urlretrieve(self, url, fname):
obj = self.get(url)
if obj == None:
try:
obj = self.get(url)
except URLTimeoutError:
return False
file(fname, "wb").write(obj.read())
self.delete(obj)
Expand Down

0 comments on commit a287732

Please sign in to comment.