Permalink
Browse files

Better handling of failed iconInPage, tidy up

git-svn-id: https://potato.codebasehq.com/getfavicon/getfavicon.svn/trunk@17 0c1c7bd3-9391-4859-b94e-4e2dcdc6a516
  • Loading branch information...
1 parent edb868a commit f9a3c874f1102c0ffa52d8886d4cf9cb5603daaa jason committed Aug 7, 2010
Showing with 17 additions and 5 deletions.
  1. +17 −5 main.py
View
22 main.py
@@ -190,8 +190,8 @@ def iconAtRoot(self):
try:
rootDomainFaviconResult = urlfetch.fetch(
- rootIconPath,
- follow_redirects = False
+ url = rootIconPath,
+ follow_redirects = False,
)
except:
@@ -231,8 +231,8 @@ def iconInPage(self):
try:
rootDomainPageResult = urlfetch.fetch(
- url=self.targetPath,
- follow_redirects = True
+ url = self.targetPath,
+ follow_redirects = True,
)
except:
@@ -250,10 +250,22 @@ def iconInPage(self):
pageIconPath = urljoin(self.targetPath,pageSoupIcon[0]["href"])
- pagePathFaviconResult = urlfetch.fetch(pageIconPath)
+ inf("Found unconfirmed iconInPage at %s" % pageIconPath)
+
+ try:
+
+ pagePathFaviconResult = urlfetch.fetch(pageIconPath)
+
+ except:
+
+ inf("Failed to retrieve icon to found in page")
+
+ return False
if pagePathFaviconResult.status_code == 200 and len(pagePathFaviconResult.content) > 0 and len(pagePathFaviconResult.content) < 20000:
+ inf("Got iconInPage, length %d bytes" % (len(pagePathFaviconResult.content)))
+
self.icon = pagePathFaviconResult.content
self.cacheIcon()
self.writeIcon()

0 comments on commit f9a3c87

Please sign in to comment.