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


Python ipkernel.IPKernelApp类代码示例

本文整理汇总了Python中IPython.zmq.ipkernel.IPKernelApp的典型用法代码示例。如果您正苦于以下问题:Python IPKernelApp类的具体用法?Python IPKernelApp怎么用?Python IPKernelApp使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: InternalIPKernel

class InternalIPKernel(object):
    """Class for managing an IPython kernel inside of QGIS.

    IPython normally runs kernels in seperate processes, but this setup is
    limiting in the case of QGIS because external kernels cannot access the
    data and variables that QGIS is working with. This class manages an
    in-process kernel and is capable of launching external consoles that can
    attach to the kernel.

    IPython Consoles are run as external processes because they rely on
    Version 2 of the PyQt api and QGIS is using Version 1 which is
    incompatible.
    """
    def __init__(self):
        self.ipkernel = IPKernelApp()
        self.ipkernel.initialize(['python',
            # Ensure the Kernel pre-loads the same modules as are available
            # from the QGIS python console.
            "--c='from qgis.core import *;import qgis.utils;'"])
        # Ensure we use an event loop that is QGIS-friendly.
        self.ipkernel.kernel.eventloop = loop_qgis
        self.ipkernel.start()

        # To create and track active qt consoles
        self._qtconsole_cmd = ['ipython', 'qtconsole', '--existing'] + \
                [os.path.basename(self.ipkernel.connection_file)]
        self.consoles = []

    def new_qt_console(self, evt=None):
        self.consoles.append(subprocess.Popen(self._qtconsole_cmd))

    def cleanup_consoles(self, evt=None):
        for c in self.consoles:
            c.kill()
开发者ID:carriercomm,项目名称:qgis-ipython,代码行数:34,代码来源:internal_ipkernel.py

示例2: pylab_kernel

def pylab_kernel(gui):
    """Launch and return an IPython kernel with pylab support for the desired gui
    """
    kernel = IPKernelApp()
    kernel.initialize(['python', '--pylab=%s' % gui,
                       #'--log-level=10'
                       ])
    return kernel
开发者ID:AhmedPho,项目名称:ipython,代码行数:8,代码来源:internal_ipkernel.py

示例3: pylab_kernel

def pylab_kernel(gui):
    """Launch and return an IPython kernel with pylab support for the desired gui
    """
    kernel = IPKernelApp()
    # FIXME: we're hardcoding the heartbeat port b/c of a bug in IPython 0.11
    # that will set it to 0 if not specified.  Once this is fixed, the --hb
    # parameter can be omitted and all ports will be automatic
    kernel.initialize(['python', '--pylab=%s' % gui, '--hb=19999',
                       #'--log-level=10'
                       ])
    return kernel
开发者ID:Paolopost,项目名称:fos,代码行数:11,代码来源:fosapp.py

示例4: get_connection_file

def get_connection_file(app=None):
    """Return the path to the connection file of an app
    
    Parameters
    ----------
    app : KernelApp instance [optional]
        If unspecified, the currently running app will be used
    """
    if app is None:
        from IPython.zmq.ipkernel import IPKernelApp
        if not IPKernelApp.initialized():
            raise RuntimeError("app not specified, and not in a running Kernel")

        app = IPKernelApp.instance()
    return filefind(app.connection_file, ['.', app.profile_dir.security_dir])
开发者ID:BlackEarth,项目名称:portable-python-win32,代码行数:15,代码来源:kernel.py

示例5: pylab_kernel

 def pylab_kernel(self,gui):
     '''Launch an IPython kernel with pylab support for the gui.'''
     log_debug,pdb,trace = False,True,False
     tag = 'leoIPython.py:pylab_kernel'
     kernel = IPKernelApp.instance()
         # IPKernalApp is a singleton class.
         # Return the singleton instance, creating it if necessary.
     if kernel:
         # pylab is needed for Qt event loop integration.
         args = ['python','--pylab=%s' % (gui)]
         if log_debug: args.append('--debug')
             #'--log-level=10'
             # '--pdb', # User-level debugging
         try:
             if pdb: g.pdb()
             kernel.initialize(args)
             # kernel objects: (Leo --ipython arg)
                 # kernel.session: zmq.session.Session
                 # kernel.shell: ZMQInteractiveShell
                 # kernel.shell.comm_manager: comm.manager.CommManager.
                 # kernel.shell.event = events.EventManager
                 # kernel.shell.run_cell (method)
                 # kernel.shell.hooks
         except Exception:
             sys.stdout = sys.__stdout__
             print('%s: kernel.initialize failed!' % tag)
             raise
     else:
         print('%s IPKernelApp.instance failed' % (tag))
     return kernel
开发者ID:jurov,项目名称:leo-editor,代码行数:30,代码来源:leoIPython.py

示例6: init_ipython

def init_ipython():
    """
    Encapsulate Kernel creation logic: Only the kernel client, manager and shell are exposed
    This is in order to ensure interoperability between major IPython changes
    """
    if ipython_1:
        manager = QtInProcessKernelManager()
        manager.start_kernel()
        manager.kernel.gui = 'qt4'
        shell = manager.kernel.shell
        shell.run_cell('%pylab inline')
        client = manager.client()
        client.start_channels()
    else:
        def event_loop(kernel):
            kernel.timer = QTimer()
            kernel.timer.timeout.connect(kernel.do_one_iteration)
            kernel.timer.start(1000 * kernel._poll_interval)

        kernel_app = IPKernelApp.instance()
        kernel_app.initialize(['python', '--pylab=qt'])     # at this point, print() won’t work anymore
        kernel_app.kernel.eventloop = event_loop

        connection_file = find_connection_file(kernel_app.connection_file)
        manager = QtKernelManager(connection_file=connection_file)
        manager.load_connection_file()
        manager.start_channels()

        kernel_app.start()

        client = None
        shell = kernel_app.shell

    return client, manager, shell
开发者ID:hlamer,项目名称:kate,代码行数:34,代码来源:python_console_ipython.py

示例7: bind_kernel

def bind_kernel(**kwargs):
    """Bind an Engine's Kernel to be used as a full IPython kernel.
    
    This allows a running Engine to be used simultaneously as a full IPython kernel
    with the QtConsole or other frontends.
    
    This function returns immediately.
    """
    from IPython.zmq.ipkernel import IPKernelApp
    from IPython.parallel.apps.ipengineapp import IPEngineApp
    
    # first check for IPKernelApp, in which case this should be a no-op
    # because there is already a bound kernel
    if IPKernelApp.initialized() and isinstance(IPKernelApp._instance, IPKernelApp):
        return
    
    if IPEngineApp.initialized():
        try:
            app = IPEngineApp.instance()
        except MultipleInstanceError:
            pass
        else:
            return app.bind_kernel(**kwargs)
    
    raise RuntimeError("bind_kernel be called from an IPEngineApp instance")
开发者ID:fccoelho,项目名称:ipython,代码行数:25,代码来源:__init__.py

示例8: __init__

 def __init__(self):
     self._app = IPKernelApp.instance()
     self._app.initialize()
     fh = logging.FileHandler(self.__class__.__name__ + ".log")
     fh.setLevel(logging.DEBUG)
     log = self._app.kernel.log
     log.setLevel(logging.DEBUG)
     log.addHandler(fh)
     log.debug("kernel init")
开发者ID:imatthewbrown,项目名称:kate,代码行数:9,代码来源:qgdb.py

示例9: pylab_kernel

def pylab_kernel(gui):
    """Launch and return an IPython kernel with pylab support for the desired gui
    """
    kernel = IPKernelApp.instance()
    # pylab is really needed, for Qt event loop integration
    kernel.initialize(['python', '--pylab=%s' % gui,
                       #'--log-level=10'
                       ])
    return kernel
开发者ID:chiamingyen,项目名称:misc,代码行数:9,代码来源:internal_ipkernel.py

示例10: pylab_kernel

def pylab_kernel(gui):
    """Launch and return an IPython kernel with pylab support for the desired gui
    """
    kernel = IPKernelApp.instance()
    # Note: pylab command seems to be needed for event loop to behave nicely
    kernel.initialize([get_executable(), '--pylab=%s' % gui,
            "--c='%run -m mantidplotrc'"])
    
    return kernel
开发者ID:trnielsen,项目名称:mantid,代码行数:9,代码来源:internal_ipkernel.py

示例11: fork_kernel

 def fork_kernel(self, config, pipe, resource_limits, logfile):
     os.setpgrp()
     logging.basicConfig(filename=self.filename,format=str(uuid.uuid4()).split('-')[0]+': %(asctime)s %(message)s',level=logging.DEBUG)
     ka = IPKernelApp.instance(config=config, ip=config["ip"])
     ka.initialize([])
     if self.update_function is not None:
         self.update_function(ka)
     for r, limit in resource_limits.iteritems():
         resource.setrlimit(getattr(resource, r), (limit, limit))
     pipe.send({"ip": ka.ip, "key": ka.session.key, "shell_port": ka.shell_port,
             "stdin_port": ka.stdin_port, "hb_port": ka.hb_port, "iopub_port": ka.iopub_port})
     pipe.close()
     ka.start()
开发者ID:kramer314,项目名称:sagecell,代码行数:13,代码来源:forking_kernel_manager.py

示例12: __init__

    def __init__(self):
        self.ipkernel = IPKernelApp()
        self.ipkernel.initialize(['python',
            # Ensure the Kernel pre-loads the same modules as are available
            # from the QGIS python console.
            "--c='from qgis.core import *;import qgis.utils;'"])
        # Ensure we use an event loop that is QGIS-friendly.
        self.ipkernel.kernel.eventloop = loop_qgis
        self.ipkernel.start()

        # To create and track active qt consoles
        self._qtconsole_cmd = ['ipython', 'qtconsole', '--existing'] + \
                [os.path.basename(self.ipkernel.connection_file)]
        self.consoles = []
开发者ID:carriercomm,项目名称:qgis-ipython,代码行数:14,代码来源:internal_ipkernel.py

示例13: fork_kernel

 def fork_kernel(self, sage_dict, config, q):
     ka = IPKernelApp.instance(config=config)
     ka.initialize([])
     ka.kernel.shell.user_ns.update(sage_dict)
     ka.kernel.shell.user_ns.update(interact.classes)
     if "sys" in ka.kernel.shell.user_ns:
         ka.kernel.shell.user_ns["sys"]._interacts = interact.interacts
     else:
         sys._interacts = interact.interacts
         ka.kernel.shell.user_ns["sys"] = sys
     ka.kernel.shell.user_ns["interact"] = interact.interact_func(ka.session, ka.iopub_socket)
     q.send({"ip": ka.ip, "key": ka.session.key, "shell_port": ka.shell_port,
             "stdin_port": ka.stdin_port, "hb_port": ka.hb_port, "iopub_port": ka.iopub_port})
     q.close()
     ka.start()
开发者ID:kcrisman,项目名称:sagecell,代码行数:15,代码来源:forking_kernel_manager.py

示例14: pylab_kernel

 def pylab_kernel(self,gui):
     """Launch and return an IPython kernel with pylab support for the desired gui
     """
     trace = True
     tag = 'leoIPython.py'
     kernel = IPKernelApp.instance()
     if kernel:
         # pylab is really needed, for Qt event loop integration.
         try:
             kernel.initialize(['python','--pylab=%s' % (gui)])
                 #'--log-level=10'
             if trace: print('%s: kernel: %s' % (tag,kernel))
         except Exception:
             print('%s: kernel.initialize failed!' % tag)
             raise
     else:
         print('%s IPKernelApp.instance failed' % (tag))
     return kernel
开发者ID:Armagedoom,项目名称:leo-editor,代码行数:18,代码来源:leoIPython.py

示例15: __init__

    def __init__(self, gui, shell):
        self.shell = shell
        self.logger = None

        if shell is None:
            # Start IPython kernel with GUI event loop support
            self.ipkernel = IPKernelApp.instance()
            self.ipkernel.initialize(['python', '--gui=%s' % gui,
                                      #'--log-level=10'  # for debugging
                                      ])
            # This application will also act on the shell user namespace
            self.namespace = self.ipkernel.shell.user_ns

        else:
            self.ipkernel = shell.config.IPKernelApp
            self.namespace = shell.user_ns

        # To create and track active qt consoles
        self.consoles = []
开发者ID:Cadair,项目名称:ginga,代码行数:19,代码来源:ipg.py


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