1#!/usr/local/bin/python3.8 2 3import sys 4import os 5import locale 6import gettext 7 8if 'LOLLYPOP_TRACE' in os.environ: 9 from pycallgraph import PyCallGraph 10 from pycallgraph.output import GraphvizOutput 11# Make sure we'll find the pygobject module, even in JHBuild 12sys.path.insert(1, '@PYTHON_DIR@') 13 14from gi.repository import Gio 15 16localedir = '@LOCALE_DIR@' 17pkgdatadir = '@DATA_DIR@' 18 19import gi 20gi.require_version("Gtk", "3.0") 21from gi.repository import Gtk 22 23def install_excepthook(): 24 """ Make sure we exit when an unhandled exception occurs. """ 25 old_hook = sys.excepthook 26 27 def new_hook(etype, evalue, etb): 28 old_hook(etype, evalue, etb) 29 while Gtk.main_level(): 30 Gtk.main_quit() 31 sys.exit() 32 sys.excepthook = new_hook 33 34if __name__ == "__main__": 35 install_excepthook() 36 37 locale.bindtextdomain('lollypop', localedir) 38 locale.textdomain('lollypop') 39 gettext.bindtextdomain('lollypop', localedir) 40 gettext.textdomain('lollypop') 41 42 resource = Gio.resource_load(os.path.join(pkgdatadir, 'lollypop.gresource')) 43 Gio.Resource._register(resource) 44 45 from lollypop.application import Application 46 app_id = None if "@APPID@" == "None" else "@APPID@" 47 app = Application("@REVISION@", pkgdatadir, app_id) 48 if 'LOLLYPOP_TRACE' in os.environ: 49 graphviz = GraphvizOutput() 50 graphviz.output_file = 'lollypop.png' 51 with PyCallGraph(output=graphviz): 52 exit_status = app.run(sys.argv) 53 sys.exit(exit_status) 54 else: 55 exit_status = app.run(sys.argv) 56 sys.exit(exit_status) 57