-2
如何知道哪些文件被调用文件系统中的文件,就像file1.exe呼吁file2.exe
所以file2.exe被修改,
和file1.exe被输入到日志文件中。如何知道哪些文件被调用的文件,文件系统
winos
我已经搜索Internet,但无法找到任何样品。
如何知道哪些文件被调用文件系统中的文件,就像file1.exe呼吁file2.exe
所以file2.exe被修改,
和file1.exe被输入到日志文件中。如何知道哪些文件被调用的文件,文件系统
winos
我已经搜索Internet,但无法找到任何样品。
为了知道哪些文件被调用一个文件,你可以使用跟踪模块
EXP:如果你有2个文件
***file1.py***
import file2
def call1():
file2.call2()
***file2.py***
def call2():
print "---------"
ü可以使用控制台使用它:
$ python -m trace --trackcalls path/to/file1.py
或在使用跟踪对象的程序中
****tracefile.py***
import trace,sys
from file1 import call1
#specify what to trace here
tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix], trace=0, count=1)
tracer.runfunc(call1) #call the function call1 in fille1
results = tracer.results()
results.write_results(summary=True, coverdir='.')
[http://pymotw.com/2/trace/#tracing-execution],[https://docs.python.org/2/library/trace.html]获取此模块的更多选项 – tparadisez