summaryrefslogtreecommitdiffstats
path: root/src/Hooks/sitecustomize.py
blob: 56c6669b762bee0a0337864e17b87d5fc70862cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# This special script is placed in
# /usr/local/lib/pythonNNN/site-packages/sitecustomize.py
# and python interpreter runs it automatically everytime
# some python script is executed

config = None
conf = {}
try:
    config = open("/etc/abrt/pyhook.conf","r")
except:
    #silently ignore if file doesn't exist
    pass

try:
    if config:
        # we expect config in form
        # key = value
        # Enabled = yes
        # this should strip
        line = config.readline().lower().replace(' ','').strip('\n').split('=')
        conf[line[0]] = line[1]
except:
    # ignore silently everything, because we don't want to bother user if this hook doesn't work
    pass

if conf.has_key("enabled"):
    if conf["enabled"] == "yes":
        try:
            from abrt_exception_handler import *

            installExceptionHandler(debug = 1)
        except Exception, e:
            # FIXME don't print anything, write it to some log file
            print e
            pass