use proxy in juick plugin

This commit is contained in:
Denis Fomin
2011-11-17 16:54:34 +03:00
parent 8b612b9847
commit 5d33b6ca5b
3 changed files with 19 additions and 20 deletions

View File

@@ -1,7 +1,7 @@
[info] [info]
name: Juick name: Juick
short_name: Juick short_name: Juick
version: 0.8 version: 0.9
description: Clickable juick links , juick nics, preview juick picturs. 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). The key combination alt + up in the textbox allow insert the number of last message (comment or topic).
authors: Denis Fomin <fominde@gmail.com> authors: Denis Fomin <fominde@gmail.com>

View File

@@ -5,7 +5,6 @@ import pango
import re import re
import os import os
import time import time
import urllib
from string import upper from string import upper
from string import rstrip from string import rstrip
import locale import locale
@@ -448,33 +447,33 @@ class Base(object):
pixbuf = self.get_pixbuf_from_url(url,self.plugin.config[ pixbuf = self.get_pixbuf_from_url(url,self.plugin.config[
'AVATAR_SIZE']) 'AVATAR_SIZE'])
if pixbuf: # save to cache
# save to cache pixbuf.save(pic_path, 'png')
pixbuf.save(pic_path, 'png') if need_check:
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 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): def get_pixbuf_from_url(self, url, size):
# download avatar and resize him # download avatar and resize him
# Returns pixbuf or False if broken image or not connected
try: try:
data = urllib.urlopen(url).read() data, alt = helpers.download_image(self.textview.account,
{'src': url})
pix = gtk.gdk.PixbufLoader() pix = gtk.gdk.PixbufLoader()
pix.write(data) pix.write(data)
pix.close() pix.close()
pixbuf = pix.get_pixbuf() pixbuf = pix.get_pixbuf()
pixbuf, w, h = self.get_pixbuf_of_size(pixbuf, size) except Exception,e:
except: img_path = self.plugin.local_file_path('unknown.png')
return False pixbuf = gtk.gdk.pixbuf_new_from_file(img_path)
pixbuf, w, h = self.get_pixbuf_of_size(pixbuf, size)
return pixbuf return pixbuf
def get_pixbuf_of_size(self, pixbuf, size): def get_pixbuf_of_size(self, pixbuf, size):

BIN
juick/unknown.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB