繁体   English   中英

Python脚本设置断点和遇到注释

[英]Python script setting breakpoints and the encounter of a comment

我正在尝试构建一个脚本,该脚本在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中运行的脚本有时成为字符串)。 我一无所知...帮助新手!

这对我有用:

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)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM