복잡한 Python 응용 프로그램 (OpenERP)에서 호출 및 코드의 흐름을 추적하려고합니다. 좀 더 복잡하게 만들기 위해 OpenERP는 정상적인 Python 상속과 평행하게 살아가는 자체 상속 시스템을 가지고 있습니다.코드의 한 지점에서 모든 문장을 추적하십시오.
모듈/함수 이름과 함께 전체 코드 목록을 실행하는 것이 좋습니다.
이클립스 디버거를 사용해 본 결과, pdb가 거의 같은 방식으로 작동하지만 프로세스를 단계별 실행하는 데 너무 오래 걸리는 것으로 알고 있습니다.
추적을 사용하여 응용 프로그램을 시작하려고 시도했지만 너무 자주 불필요한 추적을 받고 추적하기를 원합니다. 나는 모듈과 디렉토리를 제외하려고했지만 많은 도움이되지 못했다. 내가을하고 싶은 무엇
python -m trace -t --ignore-dir=/home/sean/unifield/utp729b/unifield-server --ignore-dir=/home/sean/unifield/utp729b/unifield-web --ignore-module=SocketServer,socket,threading,tiny_socket,__init__,trace,netsvc,posixpath,zipfile,config,genericpath,orm openerp-server.py --db_host=localhost --db_port=5432 --db_user=openerp --db_password=xxxx --addons-path=/home/sean/unifield/utp729b/unifield-addons,/home/sean/unifield/utp729b/sync_module_prod,/home/sean/unifield/utp729b/unifield-wm > /home/sean/trace.log
코드에 중단 점을 설정하는 것입니다, 대신 다음 코드를 단계별로 다음 파일에 로깅을 시작합니다.
또한 http://eli.thegreenplace.net/2012/08/22/easy-tracing-of-nested-function-calls-in-python/ 및 http://code.activestate.com/recipes/577551/과 같은 데코레이터를 사용해 보았지만 내 요구 사항을 충족시키지 못했습니다.
편집
지금 이클립스에서 VM 가지 인자를 상자에이 줄을 추가하여, 파이썬 추적 모듈을 사용하여 시도 : -m 추적
이 생산 시작 --trace -t 내가 뭘 찾고 있는지, 줄 단위로 추적하지만 OpenERP가 완전히 시작되면 작동이 멈춘다. 아래 콘솔 출력에서 (길게) 추출을보십시오.
pydevd_tracing.py(46): if TracingFunctionHolder._warn:
pydevd_tracing.py(62): TracingFunctionHolder._original_tracing(tracing_func)
pydevd_tracing.py(69): TracingFunctionHolder._warn = True
pydevd_tracing.py(71): TracingFunctionHolder._lock.release()
pydevd.py(1075): try:
pydevd.py(1077): threading.settrace(self.trace_dispatch) # for all future threads
pydevd.py(1081): try:
pydevd.py(1082): thread.start_new_thread = pydev_start_new_thread
pydevd.py(1083): thread.start_new = pydev_start_new_thread
pydevd.py(1087): while not self.readyToRun:
pydevd.py(1088): time.sleep(0.1) # busy wait until we receive run command
pydevd.py(1087): while not self.readyToRun:
pydevd.py(1088): time.sleep(0.1) # busy wait until we receive run command
pydevd.py(1087): while not self.readyToRun:
pydevd.py(1088): time.sleep(0.1) # busy wait until we receive run command
pydevd.py(1087): while not self.readyToRun:
pydevd.py(1088): time.sleep(0.1) # busy wait until we receive run command
pydevd.py(1087): while not self.readyToRun:
pydevd.py(1088): time.sleep(0.1) # busy wait until we receive run command
pydevd.py(1087): while not self.readyToRun:
pydevd.py(1088): time.sleep(0.1) # busy wait until we receive run command
pydevd.py(1087): while not self.readyToRun:
pydevd.py(1090): PyDBCommandThread(debugger).start()
pydevd.py(1092): pydev_imports.execfile(file, globals, locals) #execute the script
[2014-01-05 18:33:51,992][?] INFO:server:OpenERP version - 6.0.3
[2014-01-05 18:33:51,993][?] INFO:server:addons_path - /home/sean/unifield/utp729b/unifield-addons,/home/sean/unifield/utp729b/sync_module_prod,/home/sean/unifield/utp729b/unifield-wm
[2014-01-05 18:33:51,993][?] INFO:server:database hostname - localhost
[2014-01-05 18:33:51,993][?] INFO:server:database port - 5432
[2014-01-05 18:33:51,994][?] INFO:server:database user - openerp
[2014-01-05 18:33:51,994][?] INFO:server:initialising distributed objects services
[2014-01-05 18:33:52,316][?] INFO:web-services:starting HTTP service at 0.0.0.0 port 8069
[2014-01-05 18:33:52,316][?] INFO:web-services:starting HTTPS service at 0.0.0.0 port 8071
[2014-01-05 18:33:52,317][?] INFO:web-services:Registered XML-RPC over HTTP
[2014-01-05 18:33:52,318][?] INFO:web-services:starting NET-RPC service at 0.0.0.0 port 8070
[2014-01-05 18:33:52,318][?] INFO:server:Starting 3 services
[2014-01-05 18:33:52,319][?] INFO:server:OpenERP server is running, waiting for connections...
[2014-01-05 18:34:02,476][utp729b_HQ_01] INFO:init:module base: loading objects
[2014-01-05 18:34:02,478][utp729b_HQ_01] INFO:init:module base: registering objects
[2014-01-05 18:34:03,060][utp729b_HQ_01] INFO:init:module base: loading objects
[2014-01-05 18:34:03,185][utp729b_HQ_01] INFO:init:module msf_button_access_rights: loading objects
[2014-01-05 18:34:03,186][utp729b_HQ_01] INFO:init:module msf_button_access_rights: registering objects
[2014-01-05 18:34:03,203][utp729b_HQ_01] INFO:init:module spreadsheet_xml: loading objects
편집 2
보다 강력한 솔루션을 볼 수 있지만 여기에, 시간에 항상 아닌 점을 실행 한 : 내가 좋아하는 추적을 설정하는 방법을 모르는 Finding full pathname in a Python trace