Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

trace python: only include some files

I know that I can use this to trace the command execution:

python -m trace -t script.py

But I want to reduce the output: Only files which are in my src/ (pip install -e ...) should be shown.

How can I do this?

like image 226
guettli Avatar asked Sep 04 '14 13:09

guettli


1 Answers

If you are running script from bash you can use something like:

python -m trace --ignore-dir=$(python -c 'import sys ; print ":".join(sys.path)[1:]') -t ./script.py

for python3:

python -m trace --ignore-dir=$(python -c 'import sys ; print(":".join(sys.path)[1:])') -t ./script.py

In this way you can ignore if you are or not in a virtual environment or a more esoteric scenario.

like image 57
mop Avatar answered Sep 22 '22 08:09

mop