2014-04-05 2 views
0

winIDEA (이 IDE는 다른 설명이있는 프로젝트를 실행합니다)에 중단 점을 설정하는 스크립트를 작성하려고합니다. 특정 코멘트가 인식되면 중단 점을 winIDEA에 설정해야합니다. 나는이 언어에 다소 익숙하며이 스크립트를 만드는 데 문제가 있습니다. 내가 여기에 좋은지 잘 모르겠지만, 주석을 인식하는 줄을 얻으려면 노력하고 다음이 특정 줄에있는 프로그램에서 중단 점을 설정하려고합니다.파이썬 스크립트 설정 중단 점과 주석의 만남

import inspect 
import logging 

import isystem.connect as ic 
import sys 

connMgr = ic.ConnectionMgr() 
connMgr.connectMRU('') 

dbg = ic.CDebugFacade(connMgr) 
bc = ic.CBreakpointController(connMgr) 
exe = ic.CExecutionController(connMgr) 

logging.basicConfig(
    format = "%(levelname) -10s %(asctime)s %(message)s", 
    level = logging.DEBUG 

def test(): 

    caller_list = [] 
    frame = inspect.currentframe() 

    this_frame = frame # Save current frame. 

    while frame.f_back: 
     print frame 
     caller_list.append('{0}()'.format(frame.f_code.co_name)) 
     frame = frame.f_back 

    caller_line = this_frame.f_back.f_lineno 
    callers = '/'.join(reversed(caller_list)) 

    logging.info('Line {0} : {1}'.format(caller_line, callers)) 
    print caller_line 

def foo(): 
    test() 

def bar(): 
    foo() 

test() 

datafile= file(r'C:\Documents and Settings\stiral1\Desktop\function.py') 
stringfile=datafile.read() 
item_search="haha" 
counter=0 

print stringfile.find(item_search,counter) 


while counter != -1: 
    print stringfile.find(item_search,counter) 
    bc.setBP(counter,r'C:\_DevTools\winIDEA\2012\Examples\Simulator\PPC\Simple\main.c') 

내가 대신 임의의 선을 얻고, 내가 문자열 내 요소가 발생하는 위치는 (내가 IDE에서 실행되는 스크립트 어느 시점에서 문자열을). 나는 떠날 생각이 전혀 없어 ... 초보자를 도와 줘!

답변

0

이것은 나를 위해 일한 것입니다 :

def wdSetBPComment(wdPrmStr): 
    assert(wdGetNrOfSubStrings(wdPrmStr) == 2) 
    comment = wdGetSubString_1(wdPrmStr) 
    function = wdGetSubString_2(wdPrmStr) 

    gl_tpLocation.setResourceName(function) 
    gl_tpLocation.setSearch(ic.E_TRUE) 
    gl_tpLocation.setMatchingType(ic.CTestLocation.E_MATCH_PLAIN) 
    gl_tpLocation.setSearchPattern(comment) 
    lineLocation = addrCtrl.getSourceLocation(gl_tpLocation) 
    wdSetBreakpoint(lineLocation.getFileName()+lineLocation.getLineNumber()) 
    gl_bcCtrl.setBP(lineNo,fileName) 

    return (gl_wdOkStr)