How to use the ipykernel.kernelbase.Kernel function in ipykernel

To help you get started, we’ve selected a few ipykernel examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SimVascular / SimVascular / Externals / Make / 2019.02 / BuildHelpers / Jupyter / site-packages / powershell_kernel / kernel.py View on Github external
from os import unlink, environ

import base64
import imghdr
import re
import signal
import urllib

from powershell_kernel import subprocess_repl, powershell_proxy
from powershell_kernel.util import get_powershell

__version__ = '0.0.7'

version_pat = re.compile(r'version (\d+(\.\d+)+)')

class PowerShellKernel(Kernel):
    implementation = 'powershell_kernel'
    implementation_version = __version__

    @property
    def language_version(self):
        m = version_pat.search(self.banner)
        return m.group(1)

    _banner = None

    @property
    def banner(self):
        return self._banner

    language_info = {'name': 'powershell',
                     'codemirror_mode': 'shell',
github ipython / ipykernel / ipykernel / comm / comm.py View on Github external
def _default_kernel(self):
        if Kernel.initialized():
            return Kernel.instance()
github SimVascular / SimVascular / BuildWithMake / Release / Jupyter / site-packages / simvascular_tcl_kernel / kernel.py View on Github external
import base64
import imghdr
import re
import signal
import urllib

# added by me to try and add version number
from subprocess import check_output

from simvascular_tcl_kernel import subprocess_repl, simvascular_tcl_proxy

__version__ = '0.0.7'

version_pat = re.compile(r'version (\d+(\.\d+)+)')

class SimVascularTclKernel(Kernel):
    implementation = 'simvascular_tcl_kernel'
    implementation_version = __version__

    @property
    def language_version(self):
        m = version_pat.search(self.banner)
        return m.group(1)

    _banner = None

    @property
    def banner(self):
        if self._banner is None:
            self._banner = "SimVascular Version REPLACE_SV_TIMESTAMP"
        return self._banner
github benvarkey / JuVi / virtuoso_kernel / kernel.py View on Github external
from ipykernel import (
    get_connection_file, get_connection_info, connect_qtconsole
)
import signal
from .shell import VirtuosoShell, VirtuosoExceptions
from pexpect import EOF
import colorama
import re
import time
import os
import zmq

__version__ = '0.2'


class VirtuosoKernel(Kernel):
    """
    Kernel to connect virtuoso to Jupyter front-end
    """
    implementation = 'virtuoso_kernel'
    implementation_version = __version__
    language = 'SKILL'

    @property
    def language_version(self):
        """
        Language version
        """
        return self._shell.language_version

    @property
    def language_info(self):
github minrk / allthekernels / allthekernels.py View on Github external
"""
    def __init__(self, manager, shell_upstream):
        self.manager = manager
        self.shell = self.manager.connect_shell()
        self.shell_upstream = shell_upstream
        self.iopub_url = self.manager._make_url('iopub')
        IOLoop.current().add_callback(self.relay_shell)

    async def relay_shell(self):
        """Coroutine for relaying any shell replies"""
        while True:
            msg = await self.shell.recv_multipart()
            self.shell_upstream.send_multipart(msg)


class AllTheKernels(Kernel):
    """Kernel class for proxying ALL THE KERNELS YOU HAVE"""
    implementation = 'AllTheKernels'
    implementation_version = __version__
    language_info = {
        'name': 'all-of-them',
        'mimetype': 'text/plain',
    }
    banner = banner

    kernels = Dict()
    default_kernel = os.environ.get('ATK_DEFAULT_KERNEL') or 'python%i' % (sys.version_info[0])
    _atk_parent = None

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.future_context = ctx = Context()
github mathics / IMathics / imathics / kernel.py View on Github external
def __init__(self, **kwargs):
        Kernel.__init__(self, **kwargs)
        self.definitions = Definitions(add_builtin=True)        # TODO Cache
        self.definitions.set_ownvalue('$Line', Integer(0))  # Reset the line number
        self.establish_comm_manager()  # needed for ipywidgets and Manipulate[]
github Calysto / metakernel / metakernel / _metakernel.py View on Github external
def lazy_import_handle_comm_opened(*args, **kwargs):
    if Widget is None:
        return
    Widget.handle_comm_opened(*args, **kwargs)


def get_metakernel():
    """
    Get the MetaKernel instance.
    """
    return MetaKernel.meta_kernel


class MetaKernel(Kernel):
    """The base MetaKernel class."""

    app_name = 'metakernel'
    identifier_regex = r'[^\d\W][\w\.]*'
    func_call_regex = r'([^\d\W][\w\.]*)\([^\)\()]*\Z'
    magic_prefixes = dict(magic='%', shell='!', help='?')
    help_suffix = '?'
    help_links = [
        {
            'text': "MetaKernel Magics",
            'url': "https://metakernel.readthedocs.io/en/latest/source/README.html",
        },
    ]
    language_info = {
        # 'mimetype': 'text/x-python',
        # 'name': 'python',
github holoviz / panel / panel / pane / ipywidget.py View on Github external
def _get_ipywidget(self, obj, doc, root, comm, **kwargs):
        if isinstance(comm, JupyterComm) and not config.embed:
            IPyWidget = _BkIPyWidget
        else:
            import ipykernel
            from ipywidgets_bokeh.widget import IPyWidget
            from ..io.ipywidget import PanelKernel
            if not isinstance(ipykernel.kernelbase.Kernel._instance, PanelKernel):
                kernel = PanelKernel(document=doc, key=str(id(doc)).encode('utf-8'))
                for w in obj.widgets.values():
                    w.comm.kernel = kernel
                    w.comm.open()

        model = IPyWidget(widget=obj, **kwargs)
        return model
github rpep / tcl_kernel / tcl_kernel / kernel.py View on Github external
def __init__(self, **kwargs):
        Kernel.__init__(self, **kwargs)
        self.tcl = Tkinter.Tcl()
        self.execution_count = 0