diff --git a/juick/manifest.ini b/juick/manifest.ini index e6d396c..676b032 100644 --- a/juick/manifest.ini +++ b/juick/manifest.ini @@ -1,7 +1,7 @@ [info] name: Juick short_name: Juick -version: 0.8 +version: 0.9 description: Clickable juick links , juick nics, preview juick picturs. The key combination alt + up in the textbox allow insert the number of last message (comment or topic). authors: Denis Fomin diff --git a/juick/plugin.py b/juick/plugin.py index d058f60..864b4de 100644 --- a/juick/plugin.py +++ b/juick/plugin.py @@ -5,7 +5,6 @@ import pango import re import os import time -import urllib from string import upper from string import rstrip import locale @@ -448,33 +447,33 @@ class Base(object): pixbuf = self.get_pixbuf_from_url(url,self.plugin.config[ 'AVATAR_SIZE']) - if pixbuf: - # save to cache - pixbuf.save(pic_path, 'png') - if need_check: - return pixbuf - query = "select nick, id from person where nick = :nick" - self.plugin.cursor.execute(query, {'nick':nick}) - db_item = self.plugin.cursor.fetchone() - if not db_item: - data = (nick.decode('utf-8'), uid.decode('utf-8')) - self.plugin.cursor.execute('insert into person(nick, id)' - ' values (?, ?)', data) - self.plugin.conn.commit() + # save to cache + pixbuf.save(pic_path, 'png') + if need_check: return pixbuf + query = "select nick, id from person where nick = :nick" + self.plugin.cursor.execute(query, {'nick':nick}) + db_item = self.plugin.cursor.fetchone() + if not db_item: + data = (nick.decode('utf-8'), uid.decode('utf-8')) + self.plugin.cursor.execute('insert into person(nick, id)' + ' values (?, ?)', data) + self.plugin.conn.commit() + return pixbuf def get_pixbuf_from_url(self, url, size): # download avatar and resize him - # Returns pixbuf or False if broken image or not connected try: - data = urllib.urlopen(url).read() + data, alt = helpers.download_image(self.textview.account, + {'src': url}) pix = gtk.gdk.PixbufLoader() pix.write(data) pix.close() pixbuf = pix.get_pixbuf() - pixbuf, w, h = self.get_pixbuf_of_size(pixbuf, size) - except: - return False + except Exception,e: + img_path = self.plugin.local_file_path('unknown.png') + pixbuf = gtk.gdk.pixbuf_new_from_file(img_path) + pixbuf, w, h = self.get_pixbuf_of_size(pixbuf, size) return pixbuf def get_pixbuf_of_size(self, pixbuf, size): diff --git a/juick/unknown.png b/juick/unknown.png new file mode 100644 index 0000000..585fd80 Binary files /dev/null and b/juick/unknown.png differ