当前位置: 首页>>代码示例>>Python>>正文


Python InteractiveShellEmbed.call_pdb方法代码示例

本文整理汇总了Python中IPython.frontend.terminal.embed.InteractiveShellEmbed.call_pdb方法的典型用法代码示例。如果您正苦于以下问题:Python InteractiveShellEmbed.call_pdb方法的具体用法?Python InteractiveShellEmbed.call_pdb怎么用?Python InteractiveShellEmbed.call_pdb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPython.frontend.terminal.embed.InteractiveShellEmbed的用法示例。


在下文中一共展示了InteractiveShellEmbed.call_pdb方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: process_argv

# 需要导入模块: from IPython.frontend.terminal.embed import InteractiveShellEmbed [as 别名]
# 或者: from IPython.frontend.terminal.embed.InteractiveShellEmbed import call_pdb [as 别名]

#.........这里部分代码省略.........
    while True:
        # Process options up until the first filename
        (option,args) = topo_parser.parse_args(args,option)

        # Handle filename
        if args:
            filename=args.pop(0)
            #print "Executing %s" % (filename)
            filedir = os.path.dirname(os.path.abspath(filename))
            sys.path.insert(0,filedir) # Allow imports relative to this file's path
            sim_name_from_filename(filename) # Default value of topo.sim.name

            execfile(filename,__main__.__dict__)
            something_executed=True

        if not args:
            break

    global_params.check_for_unused_names()

    # OpenMP settings and defaults
    openmp_threads = __main__.__dict__.get('openmp_threads')
    if (openmp_threads is None): openmp_threads=-1

    openmp_min_threads = __main__.__dict__.get('openmp_min_threads')
    if (openmp_min_threads is None): openmp_min_threads=2

    openmp_max_threads = __main__.__dict__.get('openmp_max_threads')
    if (openmp_threads != 1): # OpenMP is disabled if openmp_threads == 1

        (num_threads, total_cores) = get_omp_num_threads(openmp_threads,
                                                         openmp_min_threads,
                                                         openmp_max_threads)

        if num_threads is None:
            print "OpenMP: Using OMP_NUM_THREADS environment variable if set. Otherwise, all cores in use."
        elif num_threads == 'NSLOTS':
            os.environ['OMP_NUM_THREADS'] =  os.environ['NSLOTS']
            print "NSLOTS environment variable found; overriding any other thread settings and using N=%s threads" % os.environ['NSLOTS']

        elif total_cores is None:
            print "OpenMP: Using %d threads" % num_threads
            os.environ['OMP_NUM_THREADS'] =  str(num_threads)
        else:
            print "OpenMP: Using %d threads on a machine with %d detected CPUs" % (num_threads, total_cores)
            os.environ['OMP_NUM_THREADS'] =  str(num_threads)

    # If no scripts and no commands were given, pretend -i was given.
    if not something_executed: interactive()

    if option.gui: topo.guimain.title(topo.sim.name)

    ## INTERACTIVE SESSION BEGINS HERE (i.e. can't have anything but
    ## some kind of cleanup code afterwards)
    if os.environ.get('PYTHONINSPECT'):
        print "Output path: %s" % param.normalize_path.prefix
        print BANNER
        # CBALERT: should probably allow a way for users to pass
        # things to IPython? Or at least set up some kind of
        # topographica ipython config file. Right now, a topo_parser
        # option has to be added for every ipython option we want to
        # support (e.g. see --pdb)

        if ipython_shell_interface == "IPython.Shell":
            # IPython 0.10 and earlier

            # Stop IPython namespace hack?
            # http://www.nabble.com/__main__-vs-__main__-td14606612.html
            __main__.__name__="__mynamespace__"

            ipython_args = ['-noconfirm_exit','-nobanner',
                            '-pi1',CommandPrompt.get_format(),
                            '-pi2',CommandPrompt2.get_format(),
                            '-po',OutputPrompt.get_format()]
            if option.pdb:
                ipython_args.append('-pdb')

            ipshell = IPShell(ipython_args,user_ns=__main__.__dict__)
            ipshell.mainloop(sys_exit=1)

        elif ipython_shell_interface == "InteractiveShellEmbed":
            # IPython 0.11 and later

            config = Config()

            if ipython_prompt_interface == "PromptManager":
                config.PromptManager.in_template = CommandPrompt.get_format()
                config.PromptManager.in2_template = CommandPrompt2.get_format()
                config.PromptManager.out_template = OutputPrompt.get_format()
            else:
                config.InteractiveShell.prompt_in1 = CommandPrompt.get_format()
                config.InteractiveShell.prompt_in2 = CommandPrompt2.get_format()
                config.InteractiveShell.prompt_out = OutputPrompt.get_format()
            config.InteractiveShell.confirm_exit = False
            ipshell = IPShell(config=config,user_ns=__main__.__dict__,
                              banner1="",exit_msg="")
            if option.pdb:
                ipshell.call_pdb = True
            ipshell()
            sys.exit()
开发者ID:antolikjan,项目名称:topographica,代码行数:104,代码来源:commandline.py


注:本文中的IPython.frontend.terminal.embed.InteractiveShellEmbed.call_pdb方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。