示例#1
0
文件: debugger.py 项目: jbalint/spark
def load_module(agent, modname):
    chron = time.time()
    succeeds = 1
    try:
        #PERSIST:INSTRUMENT        
        report_instrumentation_point(agent, PRE_USER_MODULE_LOAD)
        mod = ensure_modpath_installed(Symbol(modname))
        if not mod:
            print "=== COULD NOT INSTALL MODULE %s ==="%modname
            succeeds = 0
        currMod = get_default_module()
        #check for equality here because we are reporting instrumentation points
        if mod is not currMod:
            set_default_module(mod) 
            if not ensure_default_module_loaded(agent):
                print "=== COULD NOT LOAD MODULE %s ==="%modname
                succeeds = 0
            #PERSIST:INSTRUMENT        
            report_instrumentation_point(agent, POST_USER_MODULE_LOAD)
    except SPARKException:
        errid = NEWPM.displayError()
    chron = time.time() - chron
    print "Total Loading Time: %3.4f seconds."%chron
    #-*-*-*-*-*-* This is a hack to remove the logs from the console. A better solution is needed later.
    from spark.util.logger import get_sdl
    get_sdl().log("Default Module: %s", modname)
    return succeeds
示例#2
0
def load_module(agent, modname):
    chron = time.time()
    succeeds = 1
    try:
        # PERSIST:INSTRUMENT
        report_instrumentation_point(agent, PRE_USER_MODULE_LOAD)
        mod = ensure_modpath_installed(Symbol(modname))
        if not mod:
            print "=== COULD NOT INSTALL MODULE %s ===" % modname
            succeeds = 0
        currMod = get_default_module()
        # check for equality here because we are reporting instrumentation points
        if mod is not currMod:
            set_default_module(mod)
            if not ensure_default_module_loaded(agent):
                print "=== COULD NOT LOAD MODULE %s ===" % modname
                succeeds = 0
            # PERSIST:INSTRUMENT
            report_instrumentation_point(agent, POST_USER_MODULE_LOAD)
    except SPARKException:
        errid = NEWPM.displayError()
    chron = time.time() - chron
    print "Total Loading Time: %3.4f seconds." % chron
    # -*-*-*-*-*-* This is a hack to remove the logs from the console. A better solution is needed later.
    from spark.util.logger import get_sdl

    get_sdl().log("Default Module: %s", modname)
    return succeeds
示例#3
0
文件: sparkdoc.py 项目: jbalint/spark
def doc_module(module_name):
    """generates the documentation page for the specified module"""
    print "doc_module: ", module_name
    try:
        mod = ensure_modpath_installed(module_name)
        testagent.load_modpath(Symbol(module_name))
    except:
        print "Cannot load %s, may be part of another module"%(module_name)
        return
    
    #old: modname = mod.get_modpath().name
    modname = mod.filename
    
    has_actions = False
    has_predicates = False
    has_functions = False
    #old: syminfos = mod.get_sparkl_unit().get_exports().values()
    #new
    decls = getPackageDecls(testagent, mod.filename)
    #old: for syminfo in syminfos:
    for decl in decls:
        if decl is None:
            continue
        sym = decl.asSymbol()
        if sym.modname == modname:
            if decl.optMode(ACTION_DO):
                has_actions = True
            elif decl.optMode(PRED_SOLVE):
                has_predicates = True
            elif decl.optMode(TERM_EVAL):
                has_functions = True
    
    f = get_outputfile(module_name)
    f.write(get_header(module_name))
    f.write('<h2>Listing for module '+module_name+'</h2>'+\
            '<div class="entry">'+\
            '<p>This is auto-generated documentation.</p>'+\
            '<h4>Contents:</h4>'+\
            '<ul>')
    if has_actions:
        f.write('<li><a href="#actions">Actions</a></li>')
    if has_predicates:
        f.write('<li><a href="#predicates">Predicates</a></li>')
    if has_functions:
        f.write('<li><a href="#functions">Functions</a></li>')
        
    f.write('</ul></div>')

    if has_actions:
        f.write('<h3><a name="actions"></a><a href="#actions">Actions</a></h3>')
        doc_symbol(mod, ACTION_DO, f)
    if has_predicates:
        f.write('<h3><a name="predicates"></a><a href="#predicates">Predicates</a></h3>')    
        doc_symbol(mod, PRED_SOLVE, f)
    if has_functions:
        f.write('<h3><a name="functions"></a><a href="#functions">Functions</a></h3>')    
        doc_symbol(mod, TERM_EVAL, f)

    f.write(get_footer(module_name))
    f.close()
示例#4
0
文件: sparkdoc.py 项目: jbalint/spark
def doc_module(module_name):
    """generates the documentation page for the specified module"""
    print "doc_module: ", module_name
    try:
        mod = ensure_modpath_installed(module_name)
        testagent.load_modpath(Symbol(module_name))
    except:
        print "Cannot load %s, may be part of another module" % (module_name)
        return

    #old: modname = mod.get_modpath().name
    modname = mod.filename

    has_actions = False
    has_predicates = False
    has_functions = False
    #old: syminfos = mod.get_sparkl_unit().get_exports().values()
    #new
    decls = getPackageDecls(testagent, mod.filename)
    #old: for syminfo in syminfos:
    for decl in decls:
        if decl is None:
            continue
        sym = decl.asSymbol()
        if sym.modname == modname:
            if decl.optMode(ACTION_DO):
                has_actions = True
            elif decl.optMode(PRED_SOLVE):
                has_predicates = True
            elif decl.optMode(TERM_EVAL):
                has_functions = True

    f = get_outputfile(module_name)
    f.write(get_header(module_name))
    f.write('<h2>Listing for module '+module_name+'</h2>'+\
            '<div class="entry">'+\
            '<p>This is auto-generated documentation.</p>'+\
            '<h4>Contents:</h4>'+\
            '<ul>')
    if has_actions:
        f.write('<li><a href="#actions">Actions</a></li>')
    if has_predicates:
        f.write('<li><a href="#predicates">Predicates</a></li>')
    if has_functions:
        f.write('<li><a href="#functions">Functions</a></li>')

    f.write('</ul></div>')

    if has_actions:
        f.write(
            '<h3><a name="actions"></a><a href="#actions">Actions</a></h3>')
        doc_symbol(mod, ACTION_DO, f)
    if has_predicates:
        f.write(
            '<h3><a name="predicates"></a><a href="#predicates">Predicates</a></h3>'
        )
        doc_symbol(mod, PRED_SOLVE, f)
    if has_functions:
        f.write(
            '<h3><a name="functions"></a><a href="#functions">Functions</a></h3>'
        )
        doc_symbol(mod, TERM_EVAL, f)

    f.write(get_footer(module_name))
    f.close()
示例#5
0
def find_install_module(modname):
    """this is mostly a legacy hook and has been superceded by ensure_modpath_installed"""
    return ensure_modpath_installed(Symbol(modname))
示例#6
0
def find_install_module(modname):
    """this is mostly a legacy hook and has been superceded by ensure_modpath_installed"""
    return ensure_modpath_installed(Symbol(modname))