當前位置: 首頁>>代碼示例>>Python>>正文


Python IPKernelApp.initialize方法代碼示例

本文整理匯總了Python中IPython.zmq.ipkernel.IPKernelApp.initialize方法的典型用法代碼示例。如果您正苦於以下問題:Python IPKernelApp.initialize方法的具體用法?Python IPKernelApp.initialize怎麽用?Python IPKernelApp.initialize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在IPython.zmq.ipkernel.IPKernelApp的用法示例。


在下文中一共展示了IPKernelApp.initialize方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: InternalIPKernel

# 需要導入模塊: from IPython.zmq.ipkernel import IPKernelApp [as 別名]
# 或者: from IPython.zmq.ipkernel.IPKernelApp import initialize [as 別名]
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,代碼行數:36,代碼來源:internal_ipkernel.py

示例2: pylab_kernel

# 需要導入模塊: from IPython.zmq.ipkernel import IPKernelApp [as 別名]
# 或者: from IPython.zmq.ipkernel.IPKernelApp import initialize [as 別名]
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,代碼行數:10,代碼來源:internal_ipkernel.py

示例3: pylab_kernel

# 需要導入模塊: from IPython.zmq.ipkernel import IPKernelApp [as 別名]
# 或者: from IPython.zmq.ipkernel.IPKernelApp import initialize [as 別名]
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,代碼行數:13,代碼來源:fosapp.py

示例4: locals

# 需要導入模塊: from IPython.zmq.ipkernel import IPKernelApp [as 別名]
# 或者: from IPython.zmq.ipkernel.IPKernelApp import initialize [as 別名]
    sys.path.remove(osp.dirname(__file__))
except ValueError:
    pass


locals().pop('__file__')
__doc__ = ''
__name__ = '__main__'


if os.environ.get('IPYTHON_KERNEL', False):

    # IPython >=v0.11 Kernel
    from IPython.zmq.ipkernel import IPKernelApp
    __ipythonkernel__ = IPKernelApp().instance()
    __ipythonkernel__.initialize(sys.argv[1:])
    __ipythonshell__ = __ipythonkernel__.shell
    __ipythonkernel__.start()

elif os.environ.get('IPYTHON', False):

    sys.path.insert(0, '')
    if os.name == 'nt':
        # Windows platforms: monkey-patching *pyreadline* module
        # to make IPython work in a remote process
        from pyreadline import unicode_helper
        unicode_helper.pyreadline_codepage = "ascii"
        # For pyreadline >= v1.7:
        from pyreadline import rlmain
        class Readline(rlmain.Readline):
            def __init__(self):
開發者ID:jromang,項目名稱:retina-old,代碼行數:33,代碼來源:startup.py


注:本文中的IPython.zmq.ipkernel.IPKernelApp.initialize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。