-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathhelper.py
More file actions
16 lines (12 loc) · 578 Bytes
/
helper.py
File metadata and controls
16 lines (12 loc) · 578 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import os
import traceback
import re
SCRIPTDIR = os.path.split(os.path.dirname(__file__))[1]
def print_exception_indented(opt=None):
exc_text = traceback.format_exc()
for line in exc_text.splitlines():
# remove path information that might be sensitive
# for example, in the .pyc files for Python 2, a traceback would contain
# /home/rasmus/code/target/thirdparty/python/build/extractor-python/buildtools/install.py
line = re.sub(r'File \".*' + SCRIPTDIR + r'(.*)\",', r'File <'+ SCRIPTDIR + r'\1>', line)
print(' ' + line)