self.start = int(time.time())
bookmark.icon = None
- error, redirect_code, redirect_to, headers, content = \
+ error, http_status_code, redirect_to, headers, content = \
self.get(bookmark, bookmark.href, True)
if error:
bookmark.error = error
return 1
- if redirect_code:
- self.set_redirect(bookmark, redirect_code, redirect_to)
+ if http_status_code and (http_status_code >= 300):
+ self.set_redirect(bookmark, http_status_code, redirect_to)
return 1
size = 0
try:
_icon_url = icon_url
for i in range(8):
- error, icon_redirect_code, \
+ error, icon_status_code, \
icon_redirect_to, icon_headers, \
icon_data = \
self.get(bookmark, _icon_url)
- if icon_redirect_code:
+ if error:
+ raise IOError("No icon")
+ break
+ if icon_status_code and (
+ icon_status_code >= 300):
_icon_url = icon_redirect_to
self.log(" redirect to : %s"
% _icon_url)
if error is None:
self.proxy_ok.add(url_host)
if error is not None:
- if self.proxy and error != '404 not_found':
+ if self.proxy and r.status_code != 404:
self.log(' Proxy error : %s' % error)
if url_host not in self.proxy_ok:
self.proxy_error.add(url_host)
- return error, None, None, None, None
+ return error, r.status_code, None, None, None
if r.is_redirect:
return None, r.status_code, r.next.url, None, None
return None, None, None, r.headers, r.content
else:
self.log(' HTTP Error %s: %s' % (e.code, e.msg))
return ("HTTP Error %s: %s" % (e.code, e.msg),
- None, None, None, None)
+ e.code, None, None, None)
except urllib2.URLError as e:
self.log(' URL Error: %s' % e.reason)