Package list mirage / 9df7c63
Print exceptions to stderr instead of ignoring them Thomas Ross 1 year, 6 months ago
1 changed file(s) with 54 addition(s) and 43 deletion(s). Raw diff Collapse all Expand all
434434 icon_path = self.find_path("mirage.png")
435435 try:
436436 Gtk.Window.set_default_icon_from_file(icon_path)
437 except:
438 pass
437 except Exception as e:
438 print(e, file=sys.stderr)
439439 vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
440440
441441 # Hidden hotkeys
812812 pix = self.pixbuf_add_border(pix)
813813 try:
814814 self.thumblist[imgnum] = [pix]
815 except:
816 pass
815 except Exception as e:
816 print(e, file=sys.stderr)
817817 self.thumbscroll.get_vscrollbar().handler_unblock(
818818 self.thumb_scroll_handler
819819 )
865865 [uri, file_mtime, "Mirage" + __version__],
866866 )
867867 return pix
868 except:
868 except Exception as e:
869 print(e, file=sys.stderr)
869870 return None
870871
871872 def thumbpane_load_image(self, treeview, imgnum):
884885 if not self.thumbnail_loaded[imgnum]:
885886 self.thumbpane_set_image(self.image_list[imgnum], imgnum)
886887 GLib.idle_add(self.thumbpane_load_image, treeview, imgnum)
887 except:
888 pass
888 except Exception as e:
889 print(e, file=sys.stderr)
889890
890891 def thumbpane_select(self, imgnum):
891892 if self.thumbpane_show:
894895 path = Gtk.TreePath(imgnum)
895896 self.thumbpane.get_selection().select_path(path)
896897 self.thumbpane.scroll_to_cell(path)
897 except:
898 pass
898 except Exception as e:
899 print(e, file=sys.stderr)
899900 self.thumbpane.get_selection().handler_unblock(self.thumb_sel_handler)
900901
901902 def thumbpane_set_size(self):
925926 imgheight
926927 ) # Account for border that will be added to thumbnails..
927928 imgwidth = self.thumbnail_size
928 except:
929 except Exception as e:
930 print(e, file=sys.stderr)
929931 imgheight = 2 + self.thumbnail_size
930932 imgwidth = self.thumbnail_size
931933 blank_pix = GdkPixbuf.Pixbuf.new(
11501152 self.parse_action_command(
11511153 self.action_commands[i], self.action_batch[i]
11521154 )
1153 except:
1154 pass
1155 except Exception as e:
1156 print(e, file=sys.stderr)
11551157
11561158 break
11571159
12521254 ].get_name()
12531255 if self.filetype_is_writable(filetype):
12541256 self.action_group.lookup_action("save-image").set_enabled(enable)
1255 except:
1256 pass
1257 except Exception as e:
1258 print(e, file=sys.stderr)
12571259
12581260 for action in self.action_group.list_actions():
12591261 if action.startswith("custom-"):
14051407 - self.layout.get_hadjustment().get_page_size()
14061408 ):
14071409 self.layout.get_hadjustment().set_value(newvalue)
1408 except:
1409 pass
1410 except Exception as e:
1411 print(e, file=sys.stderr)
14101412 if self.vscroll.get_property("visible"):
14111413 try:
14121414 newvalue = abs(
14191421 ):
14201422 self.layout.get_vadjustment().set_value(newvalue)
14211423 self.previmg_width = self.currimg_width
1422 except:
1423 pass
1424 except Exception as e:
1425 print(e, file=sys.stderr)
14241426 self.updating_adjustments = False
14251427
14261428 def window_resized(self, widget, allocation, force_update=False):
16761678 self.save_image_as(None, None, None)
16771679 else:
16781680 error_dialog.destroy()
1679 except:
1681 except Exception as e:
1682 print(e, file=sys.stderr)
16801683 error_dialog = Gtk.MessageDialog(
16811684 self.window,
16821685 Gtk.DialogFlags.MODAL,
19821985 + str(ratio)
19831986 + "% "
19841987 )
1985 except:
1988 except Exception as e:
1989 print(e, file=sys.stderr)
19861990 status_text = _("Cannot load image.")
19871991 self.statusbar.push(self.statusbar.get_context_id(""), status_text)
19881992 status_text = ""
39713975 self_get_name(self.currimg_name)[1],
39723976 self.thumbnail_get_name(new_filename)[1],
39733977 )
3974 except:
3975 pass
3978 except Exception as e:
3979 print(e, file=sys.stderr)
39763980 self.recent_file_remove_and_refresh(self.currimg_name)
39773981 self.currimg_name = new_filename
39783982 self.register_file_with_recent_docs(self.currimg_name)
39793983 self.update_title()
3980 except:
3984 except Exception as e:
3985 print(e, file=sys.stderr)
39813986 error_dialog = Gtk.MessageDialog(
39823987 self.window,
39833988 Gtk.DialogFlags.MODAL,
40394044 self.image_modified = False
40404045 try:
40414046 os.remove(self.thumbnail_get_name(self.currimg_name)[1])
4042 except:
4043 pass
4047 except Exception as e:
4048 print(e, file=sys.stderr)
40444049 self.recent_file_remove_and_refresh(self.currimg_name)
40454050 iter = self.thumblist.get_iter((self.curr_img_in_list,))
40464051 try:
40474052 self.thumbnail_loaded.pop(self.curr_img_in_list)
40484053 self.thumbpane_update_images()
4049 except:
4050 pass
4054 except Exception as e:
4055 print(e, file=sys.stderr)
40514056 self.thumblist.remove(iter)
40524057 templist = self.image_list
40534058 self.image_list = []
40764081 self.set_go_navigation_sensitivities(False)
40774082 # Select new item:
40784083 self.thumbpane_select(self.curr_img_in_list)
4079 except:
4084 except Exception as e:
4085 print(e, file=sys.stderr)
40804086 error_dialog = Gtk.MessageDialog(
40814087 self.window,
40824088 Gtk.DialogFlags.MODAL,
41384144 try:
41394145 self.about_dialog.set_transient_for(self.window)
41404146 self.about_dialog.set_modal(True)
4141 except:
4142 pass
4147 except Exception as e:
4148 print(e, file=sys.stderr)
41434149 self.about_dialog.set_name("Mirage")
41444150 self.about_dialog.set_version(__version__)
41454151 self.about_dialog.set_comments(_("A fast GTK+ Image Viewer."))
41754181 try:
41764182 icon_pixbuf = GdkPixbuf.Pixbuf.new_from_file(icon_path)
41774183 self.about_dialog.set_logo(icon_pixbuf)
4178 except:
4179 pass
4184 except Exception as e:
4185 print(e, file=sys.stderr)
41804186 self.about_dialog.connect("response", self.close_about)
41814187 self.about_dialog.show_all()
41824188
45724578 newpix.fill(0x858585FF)
45734579 pix.copy_area(0, 0, width, height, newpix, 1, 1)
45744580 return newpix
4575 except:
4581 except Exception as e:
4582 print(e, file=sys.stderr)
45764583 return pix
45774584
45784585 def crop_image(self, action, parameter, data):
50795086 self.imageview.set_from_pixbuf(self.currimg_pixbuf)
50805087 self.currimg_pixbuf = bak.copy()
50815088 del bak
5082 except:
5083 pass
5089 except Exception as e:
5090 print(e, file=sys.stderr)
50845091 gc.collect()
50855092
50865093 def resize_image(self, action, parameter, data):
54845491 reset_cursor,
54855492 perform_onload_action,
54865493 )
5487 except:
5494 except Exception as e:
5495 print(e, file=sys.stderr)
54885496 self.image_load_failed(True)
54895497 if preload_next_image_after:
54905498 self.preload_when_idle = GLib.idle_add(self.preload_next_image, False)
58125820 gc.collect()
58135821 if self.verbose:
58145822 print(_("Preloading: %s") % self.preloadimg_next_name)
5815 except:
5823 except Exception as e:
5824 print(e, file=sys.stderr)
58165825 self.preloadimg_next_in_list = -1
58175826
58185827 def preload_prev_image(self, use_existing_image):
58925901 gc.collect()
58935902 if self.verbose:
58945903 print(_("Preloading: %s") % self.preloadimg_prev_name)
5895 except:
5904 except Exception as e:
5905 print(e, file=sys.stderr)
58965906 self.preloadimg_prev_in_list = -1
58975907
58985908 def change_cursor(self, type):
59545964 socket.setdefaulttimeout(5)
59555965 urllib.request.urlretrieve(inputlist[itemnum], tmpfile)
59565966 inputlist[itemnum] = tmpfile
5957 except:
5958 pass
5967 except Exception as e:
5968 print(e, file=sys.stderr)
59595969 # Remove hidden files from list:
59605970 if not self.open_hidden_files:
59615971 tmplist = []
60826092 if not self.closing_app:
60836093 while Gtk.events_pending():
60846094 Gtk.main_iteration()
6085 except:
6086 pass
6095 except Exception as e:
6096 print(e, file=sys.stderr)
60876097 if first_image_came_from_dir:
60886098 self.image_list = []
60896099 # Pre-load second image:
62256235 uri = "file://"
62266236 uri = uri + urllib.request.pathname2url(os.path.abspath(imgfile))
62276237 gtk_recent_manager.add_item(uri)
6228 except:
6238 except Exception as e:
6239 print(e, file=sys.stderr)
62296240 # Isnt currently functional on win32
62306241 if sys.platform == "win32":
62316242 pass