Total Complexity | 4 |
Total Lines | 32 |
Duplicated Lines | 0 % |
Changes | 0 |
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 |