Skip to content
Snippets Groups Projects
Commit 8f645b86 authored by dkirov's avatar dkirov
Browse files

msg should be string, not object instance

  show error dialog if file_path is not a file
   or file_size is 0
parent ca6668d8
No related branches found
No related tags found
No related merge requests found
......@@ -161,7 +161,16 @@ def on_set_avatar_button_clicked(self, widget):
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 @@ def on_ok(widget, path_to_file):
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')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment