eolie.in 1.58 KB
Newer Older
1
#!@PYTHON@
Cédric Bellegarde's avatar
Cédric Bellegarde committed
2 3 4 5 6 7

import sys
import os
import locale
import gettext

8
if 'EOLIE_TRACE' in os.environ:
Cédric Bellegarde's avatar
Cédric Bellegarde committed
9 10
    from pycallgraph import PyCallGraph
    from pycallgraph.output import GraphvizOutput
11

Cédric Bellegarde's avatar
Cédric Bellegarde committed
12
# Make sure we'll find the pygobject module, even in JHBuild
13
#sys.path.insert(1, '@PYTHON_EXEC_DIR@')
14
# Make sure we'll find the eolie modules, even in JHBuild
Cédric Bellegarde's avatar
Cédric Bellegarde committed
15
sys.path.insert(1, '@PYTHON_DIR@')
Cédric Bellegarde's avatar
Cédric Bellegarde committed
16 17 18

from gi.repository import Gio

Cédric Bellegarde's avatar
Cédric Bellegarde committed
19 20 21
localedir = '@LOCALE_DIR@'
pkgdatadir = '@DATA_DIR@'
extensiondir = '@EXTENSION_DIR@'
Cédric Bellegarde's avatar
Cédric Bellegarde committed
22

23
from eolie.application import Application
Cédric Bellegarde's avatar
Cédric Bellegarde committed
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39

def install_excepthook():
    """ Make sure we exit when an unhandled exception occurs. """
    from gi.repository import Gtk
    old_hook = sys.excepthook

    def new_hook(etype, evalue, etb):
        old_hook(etype, evalue, etb)
        while Gtk.main_level():
            Gtk.main_quit()
        sys.exit()
    sys.excepthook = new_hook

if __name__ == "__main__":
    install_excepthook()
    
40 41 42 43
    locale.bindtextdomain('eolie', localedir)
    locale.textdomain('eolie')
    gettext.bindtextdomain('eolie', localedir)
    gettext.textdomain('eolie')
Cédric Bellegarde's avatar
Cédric Bellegarde committed
44

45
    resource = Gio.resource_load(os.path.join(pkgdatadir, 'eolie.gresource'))
Cédric Bellegarde's avatar
Cédric Bellegarde committed
46 47
    Gio.Resource._register(resource)

Cédric Bellegarde's avatar
Cédric Bellegarde committed
48
    app = Application("@VERSION@", os.path.join(extensiondir, 'webkitextension'))
49
    if 'EOLIE_TRACE' in os.environ:
Cédric Bellegarde's avatar
Cédric Bellegarde committed
50
        graphviz = GraphvizOutput()
51
        graphviz.output_file = 'eolie.png'
Cédric Bellegarde's avatar
Cédric Bellegarde committed
52 53 54 55 56 57
        with PyCallGraph(output=graphviz):
            exit_status = app.run(sys.argv)
            sys.exit(exit_status)
    else:
        exit_status = app.run(sys.argv)
        sys.exit(exit_status)