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:
Dimitur Kirov 2006-04-12 14:47:31 +00:00
parent ca6668d83e
commit 8f645b8661
1 changed files with 16 additions and 2 deletions

View File

@ -161,7 +161,16 @@ class VcardWindow:
f = None f = None
def on_ok(widget, path_to_file): def on_ok(widget, path_to_file):
filesize = os.path.getsize(path_to_file) # in bytes 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: try:
pixbuf = gtk.gdk.pixbuf_new_from_file(path_to_file) pixbuf = gtk.gdk.pixbuf_new_from_file(path_to_file)
# get the image at 'notification size' # get the image at 'notification size'
@ -169,9 +178,14 @@ class VcardWindow:
scaled_pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf, scaled_pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf,
'notification') 'notification')
except gobject.GError, msg: # unknown format 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) dialogs.ErrorDialog(_('Could not load image'), msg)
return return
else: if filesize > 16384:
if scaled_pixbuf: if scaled_pixbuf:
path_to_file = os.path.join(gajim.TMP, path_to_file = os.path.join(gajim.TMP,
'avatar_scaled.png') 'avatar_scaled.png')