msg should be string, not object instance
show error dialog if file_path is not a file or file_size is 0
This commit is contained in:
parent
ca6668d83e
commit
8f645b8661
18
src/vcard.py
18
src/vcard.py
|
@ -161,7 +161,16 @@ class VcardWindow:
|
|||
f = None
|
||||
def on_ok(widget, path_to_file):
|
||||
filesize = os.path.getsize(path_to_file) # in bytes
|
||||
if filesize > 16384: # 16 kb
|
||||
#FIXME: use messages for invalid file for 0.11
|
||||
invalid_file = False
|
||||
msg = ''
|
||||
if os.path.isfile(path_to_file):
|
||||
stat = os.stat(path_to_file)
|
||||
if stat[6] == 0:
|
||||
invalid_file = True
|
||||
else:
|
||||
invalid_file = True
|
||||
if not invalid_file and filesize > 16384: # 16 kb
|
||||
try:
|
||||
pixbuf = gtk.gdk.pixbuf_new_from_file(path_to_file)
|
||||
# get the image at 'notification size'
|
||||
|
@ -169,9 +178,14 @@ class VcardWindow:
|
|||
scaled_pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf,
|
||||
'notification')
|
||||
except gobject.GError, msg: # unknown format
|
||||
# msg should be string, not object instance
|
||||
msg = str(msg)
|
||||
invalid_file = True
|
||||
if invalid_file:
|
||||
if True: # keep identation
|
||||
dialogs.ErrorDialog(_('Could not load image'), msg)
|
||||
return
|
||||
else:
|
||||
if filesize > 16384:
|
||||
if scaled_pixbuf:
|
||||
path_to_file = os.path.join(gajim.TMP,
|
||||
'avatar_scaled.png')
|
||||
|
|
Loading…
Reference in New Issue