- raise RedirectException("html", "%s (%d sec)" % (url, timeout))
- except KeyError:
- pass
-
- except IOError, msg:
- if (msg[0] == "http error") and (msg[1] == -1):
- bookmark.no_error = "The server did not return any header - it is not an error, actually"
- else:
- bookmark.error = get_error(msg)
-
- except EOFError:
- bookmark.error = "Unexpected EOF (FTP server closed connection)"
-
- except RedirectException, msg:
- bookmark.moved = str(msg)
-
- except KeyboardInterrupt:
- return 0
+ raise IOError("Too many redirects")
+ except:
+ etype, emsg, tb = sys.exc_info()
+ self.log(" no icon : %s %s" % (etype, emsg))
+ etype = None
+ emsg = None
+ tb = None
+ icons[icon] = None
+ else:
+ content_type = headers["Content-Type"]
+ if content_type.startswith("image/"):
+ icon_file = open(fname, "rb")
+ icon = icon_file.read()
+ icon_file.close()
+ bookmark.icon = "data:%s;base64,%s" % (content_type, b64encode(icon))
+ self.log(" got icon : %s" % content_type)
+ icons[icon] = (content_type, bookmark.icon)
+ else:
+ self.log(" no icon : bad content type '%s'" % content_type)
+ icons[icon] = None
+ os.remove(fname)
+
+ except KeyError, key:
+ self.log(" no header: %s" % key)
+
+ except IOError, msg:
+ if (msg[0] == "http error") and (msg[1] == -1):
+ bookmark.no_error = "The server did not return any header - it is not an error, actually"
+ self.log(bookmark.no_error)
+ else:
+ bookmark.error = get_error(msg)
+ self.log(bookmark.error)
+
+ except EOFError:
+ bookmark.error = "Unexpected EOF (FTP server closed connection)"
+ self.log(bookmark.error)
+
+ except RedirectException, msg:
+ bookmark.moved = str(msg)
+ self.log(bookmark.moved)
+
+ except KeyboardInterrupt:
+ self.log("Keyboard interrupt (^C)")
+ return 0
+
+ except:
+ import traceback
+ traceback.print_exc()
+ bookmark.error = "Exception!"
+ self.log(bookmark.error)