From 8f645b86611a545e53eec1250ce8fac82dbd0c3e Mon Sep 17 00:00:00 2001 From: Dimitur Kirov Date: Wed, 12 Apr 2006 14:47:31 +0000 Subject: [PATCH] msg should be string, not object instance show error dialog if file_path is not a file or file_size is 0 --- src/vcard.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/vcard.py b/src/vcard.py index 9853571fa..427f827c0 100644 --- a/src/vcard.py +++ b/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')