Completed
Push — master ( b70cc6...229cac )
by Thomas
35:29 queued 20:32
created

exabgp.debug.intercept   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 4

3 Functions

Rating   Name   Duplication   Size   Complexity  
A trace_interceptor() 0 2 1
A bug_report() 0 5 1
A intercept() 0 4 2
1
# encoding: utf-8
2
"""
3
debug.py
4
5
Created by Thomas Mangin on 2011-03-29.
6
Copyright (c) 2009-2017 Exa Networks. All rights reserved.
7
License: 3-clause BSD. (See the COPYRIGHT file)
8
"""
9
10
import os
11
import sys
12
import pdb
13
14
from exabgp.debug.report import format_panic
15
16
17
def bug_report(dtype, value, trace):
18
    sys.stdout.flush()
19
    sys.stderr.flush()
20
    print(format_panic(dtype, value, trace))
21
    sys.stdout.flush()
22
23
24
def intercept(dtype, value, trace):
25
    bug_report(dtype, value, trace)
26
    if os.environ.get('PDB', None) not in [None, '0', '']:
27
        pdb.pm()
28
29
30
def trace_interceptor():
31
    sys.excepthook = intercept
32
33