Package list mirage / be0968f
Use traceback to format exception information Thomas Ross 1 year, 6 months ago
1 changed file(s) with 55 addition(s) and 54 deletion(s). Raw diff Collapse all Expand all
3030 import random, urllib.request, locale
3131 import stat, time, subprocess, shutil, filecmp
3232 import tempfile, socket, threading
33 import traceback
3334
3435 from .fullscreen_controls import FullscreenControls
3536
434435 icon_path = self.find_path("mirage.png")
435436 try:
436437 Gtk.Window.set_default_icon_from_file(icon_path)
437 except Exception as e:
438 print(e, file=sys.stderr)
438 except:
439 print(traceback.format_exc(), file=sys.stderr)
439440 vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
440441
441442 # Hidden hotkeys
812813 pix = self.pixbuf_add_border(pix)
813814 try:
814815 self.thumblist[imgnum] = [pix]
815 except Exception as e:
816 print(e, file=sys.stderr)
816 except:
817 print(traceback.format_exc(), file=sys.stderr)
817818 self.thumbscroll.get_vscrollbar().handler_unblock(
818819 self.thumb_scroll_handler
819820 )
865866 [uri, file_mtime, "Mirage" + __version__],
866867 )
867868 return pix
868 except Exception as e:
869 print(e, file=sys.stderr)
869 except:
870 print(traceback.format_exc(), file=sys.stderr)
870871 return None
871872
872873 def thumbpane_load_image(self, treeview, imgnum):
885886 if not self.thumbnail_loaded[imgnum]:
886887 self.thumbpane_set_image(self.image_list[imgnum], imgnum)
887888 GLib.idle_add(self.thumbpane_load_image, treeview, imgnum)
888 except Exception as e:
889 print(e, file=sys.stderr)
889 except:
890 print(traceback.format_exc(), file=sys.stderr)
890891
891892 def thumbpane_select(self, imgnum):
892893 if self.thumbpane_show:
895896 path = Gtk.TreePath(imgnum)
896897 self.thumbpane.get_selection().select_path(path)
897898 self.thumbpane.scroll_to_cell(path)
898 except Exception as e:
899 print(e, file=sys.stderr)
899 except:
900 print(traceback.format_exc(), file=sys.stderr)
900901 self.thumbpane.get_selection().handler_unblock(self.thumb_sel_handler)
901902
902903 def thumbpane_set_size(self):
926927 imgheight
927928 ) # Account for border that will be added to thumbnails..
928929 imgwidth = self.thumbnail_size
929 except Exception as e:
930 print(e, file=sys.stderr)
930 except:
931 print(traceback.format_exc(), file=sys.stderr)
931932 imgheight = 2 + self.thumbnail_size
932933 imgwidth = self.thumbnail_size
933934 blank_pix = GdkPixbuf.Pixbuf.new(
11521153 self.parse_action_command(
11531154 self.action_commands[i], self.action_batch[i]
11541155 )
1155 except Exception as e:
1156 print(e, file=sys.stderr)
1156 except:
1157 print(traceback.format_exc(), file=sys.stderr)
11571158
11581159 break
11591160
12541255 ].get_name()
12551256 if self.filetype_is_writable(filetype):
12561257 self.action_group.lookup_action("save-image").set_enabled(enable)
1257 except Exception as e:
1258 print(e, file=sys.stderr)
1258 except:
1259 print(traceback.format_exc(), file=sys.stderr)
12591260
12601261 for action in self.action_group.list_actions():
12611262 if action.startswith("custom-"):
14071408 - self.layout.get_hadjustment().get_page_size()
14081409 ):
14091410 self.layout.get_hadjustment().set_value(newvalue)
1410 except Exception as e:
1411 print(e, file=sys.stderr)
1411 except:
1412 print(traceback.format_exc(), file=sys.stderr)
14121413 if self.vscroll.get_property("visible"):
14131414 try:
14141415 newvalue = abs(
14211422 ):
14221423 self.layout.get_vadjustment().set_value(newvalue)
14231424 self.previmg_width = self.currimg_width
1424 except Exception as e:
1425 print(e, file=sys.stderr)
1425 except:
1426 print(traceback.format_exc(), file=sys.stderr)
14261427 self.updating_adjustments = False
14271428
14281429 def window_resized(self, widget, allocation, force_update=False):
16811682 self.save_image_as(None, None, None)
16821683 else:
16831684 error_dialog.destroy()
1684 except Exception as e:
1685 print(e, file=sys.stderr)
1685 except:
1686 print(traceback.format_exc(), file=sys.stderr)
16861687 error_dialog = Gtk.MessageDialog(
16871688 self.window,
16881689 Gtk.DialogFlags.MODAL,
19941995 + str(ratio)
19951996 + "% "
19961997 )
1997 except Exception as e:
1998 print(e, file=sys.stderr)
1998 except:
1999 print(traceback.format_exc(), file=sys.stderr)
19992000 status_text = _("Cannot load image.")
20002001 self.statusbar.push(self.statusbar.get_context_id(""), status_text)
20012002 status_text = ""
39923993 self_get_name(self.currimg_name)[1],
39933994 self.thumbnail_get_name(new_filename)[1],
39943995 )
3995 except Exception as e:
3996 print(e, file=sys.stderr)
3996 except:
3997 print(traceback.format_exc(), file=sys.stderr)
39973998 self.recent_file_remove_and_refresh(self.currimg_name)
39983999 self.currimg_name = new_filename
39994000 self.register_file_with_recent_docs(self.currimg_name)
40004001 self.update_title()
4001 except Exception as e:
4002 print(e, file=sys.stderr)
4002 except:
4003 print(traceback.format_exc(), file=sys.stderr)
40034004 error_dialog = Gtk.MessageDialog(
40044005 self.window,
40054006 Gtk.DialogFlags.MODAL,
40614062 self.image_modified = False
40624063 try:
40634064 os.remove(self.thumbnail_get_name(self.currimg_name)[1])
4064 except Exception as e:
4065 print(e, file=sys.stderr)
4065 except:
4066 print(traceback.format_exc(), file=sys.stderr)
40664067 self.recent_file_remove_and_refresh(self.currimg_name)
40674068 iter = self.thumblist.get_iter((self.curr_img_in_list,))
40684069 try:
40694070 self.thumbnail_loaded.pop(self.curr_img_in_list)
40704071 self.thumbpane_update_images()
4071 except Exception as e:
4072 print(e, file=sys.stderr)
4072 except:
4073 print(traceback.format_exc(), file=sys.stderr)
40734074 self.thumblist.remove(iter)
40744075 templist = self.image_list
40754076 self.image_list = []
40984099 self.set_go_navigation_sensitivities(False)
40994100 # Select new item:
41004101 self.thumbpane_select(self.curr_img_in_list)
4101 except Exception as e:
4102 print(e, file=sys.stderr)
4102 except:
4103 print(traceback.format_exc(), file=sys.stderr)
41034104 error_dialog = Gtk.MessageDialog(
41044105 self.window,
41054106 Gtk.DialogFlags.MODAL,
41644165 try:
41654166 self.about_dialog.set_transient_for(self.window)
41664167 self.about_dialog.set_modal(True)
4167 except Exception as e:
4168 print(e, file=sys.stderr)
4168 except:
4169 print(traceback.format_exc(), file=sys.stderr)
41694170 self.about_dialog.set_name("Mirage")
41704171 self.about_dialog.set_version(__version__)
41714172 self.about_dialog.set_comments(_("A fast GTK+ Image Viewer."))
42014202 try:
42024203 icon_pixbuf = GdkPixbuf.Pixbuf.new_from_file(icon_path)
42034204 self.about_dialog.set_logo(icon_pixbuf)
4204 except Exception as e:
4205 print(e, file=sys.stderr)
4205 except:
4206 print(traceback.format_exc(), file=sys.stderr)
42064207 self.about_dialog.connect("response", self.close_about)
42074208 self.about_dialog.show_all()
42084209
45984599 newpix.fill(0x858585FF)
45994600 pix.copy_area(0, 0, width, height, newpix, 1, 1)
46004601 return newpix
4601 except Exception as e:
4602 print(e, file=sys.stderr)
4602 except:
4603 print(traceback.format_exc(), file=sys.stderr)
46034604 return pix
46044605
46054606 def crop_image(self, action, parameter, data):
51065107 self.imageview.set_from_pixbuf(self.currimg_pixbuf)
51075108 self.currimg_pixbuf = bak.copy()
51085109 del bak
5109 except Exception as e:
5110 print(e, file=sys.stderr)
5110 except:
5111 print(traceback.format_exc(), file=sys.stderr)
51115112 gc.collect()
51125113
51135114 def resize_image(self, action, parameter, data):
55115512 reset_cursor,
55125513 perform_onload_action,
55135514 )
5514 except Exception as e:
5515 print(e, file=sys.stderr)
5515 except:
5516 print(traceback.format_exc(), file=sys.stderr)
55165517 self.image_load_failed(True)
55175518 if preload_next_image_after:
55185519 self.preload_when_idle = GLib.idle_add(self.preload_next_image, False)
58405841 gc.collect()
58415842 if self.verbose:
58425843 print(_("Preloading: %s") % self.preloadimg_next_name)
5843 except Exception as e:
5844 print(e, file=sys.stderr)
5844 except:
5845 print(traceback.format_exc(), file=sys.stderr)
58455846 self.preloadimg_next_in_list = -1
58465847
58475848 def preload_prev_image(self, use_existing_image):
59215922 gc.collect()
59225923 if self.verbose:
59235924 print(_("Preloading: %s") % self.preloadimg_prev_name)
5924 except Exception as e:
5925 print(e, file=sys.stderr)
5925 except:
5926 print(traceback.format_exc(), file=sys.stderr)
59265927 self.preloadimg_prev_in_list = -1
59275928
59285929 def change_cursor(self, type):
59845985 socket.setdefaulttimeout(5)
59855986 urllib.request.urlretrieve(inputlist[itemnum], tmpfile)
59865987 inputlist[itemnum] = tmpfile
5987 except Exception as e:
5988 print(e, file=sys.stderr)
5988 except:
5989 print(traceback.format_exc(), file=sys.stderr)
59895990 # Remove hidden files from list:
59905991 if not self.open_hidden_files:
59915992 tmplist = []
61126113 if not self.closing_app:
61136114 while Gtk.events_pending():
61146115 Gtk.main_iteration()
6115 except Exception as e:
6116 print(e, file=sys.stderr)
6116 except:
6117 print(traceback.format_exc(), file=sys.stderr)
61176118 if first_image_came_from_dir:
61186119 self.image_list = []
61196120 # Pre-load second image:
62556256 uri = "file://"
62566257 uri = uri + urllib.request.pathname2url(os.path.abspath(imgfile))
62576258 gtk_recent_manager.add_item(uri)
6258 except Exception as e:
6259 print(e, file=sys.stderr)
6259 except:
6260 print(traceback.format_exc(), file=sys.stderr)
62606261 # Isnt currently functional on win32
62616262 if sys.platform == "win32":
62626263 pass