def start_kernel(): """ Start Pytuga Jupyter kernel. """ from ipykernel.kernelapp import IPKernelApp IPKernelApp.launch_instance(kernel_class=PytugaKernel)
def main(): """launch a ROOT c++ with CutLang kernel""" try: from ipykernel.kernelapp import IPKernelApp except ImportError: from IPython.kernel.zmq.kernelapp import IPKernelApp IPKernelApp.launch_instance(kernel_class=CutLangKernel)
def main(): """launch a root kernel""" try: from ipykernel.kernelapp import IPKernelApp except ImportError: from IPython.kernel.zmq.kernelapp import IPKernelApp IPKernelApp.launch_instance(kernel_class=ROOTKernel)
def main(): kwargs = sys.argv for kwarg in kwargs[:]: if kwarg.startswith('--std='): # TODO: Handle this properly. Currently this is hard-coded in # the kernel. assert kwarg == '--std=f2008' kwargs.remove(kwarg) IPKernelApp.launch_instance(kernel_class=FortranKernel)
def start_kernel(transpyler): """ Start Jupyter kernel. """ from ipykernel.kernelapp import IPKernelApp kernel_class = with_transpyler_attr(TranspylerKernel, transpyler) IPKernelApp.launch_instance(kernel_class=kernel_class)
class PySparkKernel(SparkKernelBase): def __init__(self, **kwargs): implementation = 'PySpark' implementation_version = '1.0' language = LANG_PYTHON language_version = '0.1' language_info = { 'name': 'pyspark', 'mimetype': 'text/x-python', 'codemirror_mode': { 'name': 'python', 'version': 3 }, 'file_extension': '.py', 'pygments_lexer': 'python3' } session_language = LANG_PYTHON super(PySparkKernel, self).__init__(implementation, implementation_version, language, language_version, language_info, session_language, **kwargs) if __name__ == '__main__': from ipykernel.kernelapp import IPKernelApp IPKernelApp.launch_instance(kernel_class=PySparkKernel)
from kernel import JavaKernel if __name__ == '__main__': try: from ipykernel.kernelapp import IPKernelApp except: from IPython.kernel.zmq.kernelapp import IPKernelApp IPKernelApp.launch_instance(kernel_class=JavaKernel)
from ipykernel.kernelapp import IPKernelApp from . import DyalogKernel IPKernelApp.launch_instance(kernel_class=DyalogKernel)
from ipykernel.kernelapp import IPKernelApp from .kernel import CpsamdKernel IPKernelApp.launch_instance(kernel_class=CpsamdKernel)
}) return { "status": "error", "execution_count": self.execution_count, "traceback": [], "ename": "", "evalue": str(e) } if not silent: latex_str = latex_numeric.latex_numeric_str(num_result) self.send_response( self.iopub_socket, "display_data", { "data": { "text/latex": "${}$".format(latex_str), "text/plain": latex_str } }) return { "status": "ok", "execution_count": self.execution_count, "payload": [], "user_expressions": [] } if __name__ == '__main__': from ipykernel.kernelapp import IPKernelApp IPKernelApp.launch_instance(kernel_class=CaspyKernel)
def main(): """Launch the kernel app.""" IPKernelApp.launch_instance(kernel_class=CoconutKernel)
backend = settings["backend"] width, height = settings["size"] resolution = settings["resolution"] for k, v in { "defaultfigurevisible": backends[backend], "defaultfigurepaperpositionmode": "manual", "defaultfigurepaperposition": matlab.double([0, 0, width / resolution, height / resolution]), "defaultfigurepaperunits": "inches"}.items(): self._matlab.set(0., k, v, nargout=0) def repr(self, obj): return obj def restart_kernel(self): self._matlab.exit() self._matlab = matlab.engine.start_matlab() self._first = True def do_shutdown(self, restart): self._matlab.exit() return super(MatlabKernel, self).do_shutdown(restart) if __name__ == '__main__': try: from ipykernel.kernelapp import IPKernelApp except ImportError: from IPython.kernel.zmq.kernelapp import IPKernelApp IPKernelApp.launch_instance(kernel_class=MatlabKernel)
# # Copyright SAS Institute # # Licensed under the Apache License, Version 2.0 (the License); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # from ipykernel.kernelapp import IPKernelApp from .kernel import SASKernel IPKernelApp.launch_instance(kernel_class=SASKernel)
from ghidra_jython_kernel import GhidraJythonKernel if __name__ == '__main__': from ipykernel.kernelapp import IPKernelApp IPKernelApp.launch_instance(kernel_class=GhidraJythonKernel)
from ipykernel.kernelapp import IPKernelApp from .kernel import KdbQKernel IPKernelApp.launch_instance(kernel_class=KdbQKernel)
from ipykernel.kernelapp import IPKernelApp from .kernel import polymakeKernel IPKernelApp.launch_instance(kernel_class=polymakeKernel)
except: self._child.kill(signal.SIGKILL) return {'status':'ok', 'restart':restart} def jyrepl(self,code,timeout=None): out="" #this if is needed for printing output if command entered is "variable" or fucntions like abc(var) and for code completion # if (len(re.split(r"\=",code.strip()))==1) and (len(re.split(r"[\ ]",code.strip()))==1): # code='eval('+repr(code.strip())+')' # self._child.sendline(code) # now_prompt=self._child.expect_exact([u">>> ",u"... "]) # if len(self._child.before.splitlines())>1: out+='\n'.join(self._child.before.splitlines()[1:])+'\n' # now_prompt=self._child.expect_exact([u">>> ",u"... "]) # else: # code='exec('+repr(code)+')' # for line in code.splitlines(): # self._child.sendline(line) # now_prompt=self._child.expect_exact([u">>> ",u"... "]) # if len(self._child.before.splitlines())>1: out+='\n'.join(self._child.before.splitlines()[1:])+'\n' # now_prompt=self._child.expect_exact([u">>> ",u"... "]) code='exec('+repr(code)+')' for line in code.splitlines(): self._child.sendline(line) now_prompt=self._child.expect_exact([u">>> ",u"... "]) if len(self._child.before.splitlines())>1: out+='\n'.join(self._child.before.splitlines()[1:])+'\n' now_prompt=self._child.expect_exact([u">>> ",u"... "]) return out if __name__ == '__main__': from ipykernel.kernelapp import IPKernelApp IPKernelApp.launch_instance(kernel_class=JythonKernel)
from ipykernel.kernelapp import IPKernelApp from .kernel import RaxKernel IPKernelApp.launch_instance(kernel_class=RaxKernel)
self.send_response(self.iopub_socket, 'stream', stream_content) if interrupted: return {'status': 'abort', 'execution_count': self.execution_count} return {'status': 'ok', 'execution_count': self.execution_count, 'payload': [], 'user_expressions': {}} def do_execute_command(self, cmd, silent): interrupted = False if cmd.startswith('%'): args = shlex.split(cmd) cmd = args.pop(0)[1:] if hasattr(self, '_cmd_' + cmd): return getattr(self, '_cmd_' + cmd)(args, silent), interrupted output = '' try: output = self.msf_wrapper.run_command(cmd, timeout=self.timeout) except KeyboardInterrupt: self.msf_wrapper.child.sendintr() interrupted = True self.msf_wrapper._expect_prompt() output = self.msf_wrapper.child.before except pexpect.EOF: output = self.msf_wrapper.child.before + 'Restarting Metasploit' self._start_msfconsole() return output, interrupted if __name__ == '__main__': IPKernelApp.launch_instance(kernel_class=MetasploitKernel)
from ipykernel.kernelapp import IPKernelApp from . import PeroxidePexpectKernel IPKernelApp.launch_instance(kernel_class=PeroxidePexpectKernel)
""" Launch MPKernelStmhal """ try: from ipykernel.kernelapp import IPKernelApp except ImportError: from IPython.kernel.zmq.kernelapp import IPKernelApp from .stmhal import MPKernelStmhal # Launch the pyboard port IPKernelApp.launch_instance(kernel_class=MPKernelStmhal)
start += '(webspad::start {0} "localhost"))'.format(htport) # A couple of ways to start FriCAS # -------------------------------- # Uncomment or edit as you like. # Default: ## pid = Popen(['fricas','-eval',prereq,'-eval',start]) # Start the FriCAS process in a separate terminal. # That might be good for controlling FriCAS directly in case # the Jupyter interface hangs or a process runs too long. # Of course, the start-fricas-in-terminal way also works # with additional fricas options. pid = Popen(['gnome-terminal', '--title=jfricas', '--'] + ['fricas', '-eval', prereq, '-eval', start]) # Start the FriCAS process without opening the HyperDoc window. ## pid = Popen(['fricas','-eval',prereq,'-eval',start] + ## ['-noht]) # Start the FriCAS process by calling only FRICASsys. # The following does currently not work. ## pid = Popen(['fricas','-nosman','-eval',prereq,'-eval',start]) # but ## pid = Popen(['gnome-terminal', '--title=jfricas', '--'] + ## ['fricas','-nosman','-eval',prereq,'-eval',start]) # does. # Start the kernel. IPKernelApp.launch_instance(kernel_class=SPAD)
sbresponse = self.target.CompleteCode(self.swift_language, None, code_to_cursor) prefix = sbresponse.GetPrefix() insertable_matches = [] for i in range(sbresponse.GetNumMatches()): sbmatch = sbresponse.GetMatchAtIndex(i) insertable_match = prefix + sbmatch.GetInsertable() if insertable_match.startswith("_"): continue insertable_matches.append(insertable_match) return { 'status': 'ok', 'matches': insertable_matches, 'cursor_start': cursor_pos - len(prefix), 'cursor_end': cursor_pos, } if __name__ == '__main__': # Jupyter sends us SIGINT when the user requests execution interruption. # Here, we block all threads from receiving the SIGINT, so that we can # handle it in a specific handler thread. if hasattr(signal, 'pthread_sigmask'): # Not supported in Windows signal.pthread_sigmask(signal.SIG_BLOCK, [signal.SIGINT]) from ipykernel.kernelapp import IPKernelApp # We pass the kernel name as a command-line arg, since Jupyter gives those # highest priority (in particular overriding any system-wide config). IPKernelApp.launch_instance( argv=sys.argv + ['--IPKernelApp.kernel_class=__main__.SwiftKernel'])
from ipykernel.kernelapp import IPKernelApp from .kernel import NodeMcuKernel IPKernelApp.launch_instance(kernel_class=NodeMcuKernel)
elif silent or code.endswith(';'): self.repl += code else: output = self.eval(self.repl + code, self.get_deps()) stream_content = {'name': 'stdout', 'text': output} self.send_response(self.iopub_socket, 'stream', stream_content) return { 'status': 'ok', # The base class increments the execution count 'execution_count': self.execution_count, 'payload': [], 'user_expressions': {}, } def get_deps(self): return (' ').join(self.deps) def eval(self, code, deps): import subprocess output = subprocess.run(["re", deps, code], stdout=subprocess.PIPE) return output.stdout.decode("utf-8") if __name__ == '__main__': from ipykernel.kernelapp import IPKernelApp IPKernelApp.launch_instance(kernel_class=IRustKernel)
from ipykernel.kernelapp import IPKernelApp from .kernel import AnsibleKernel IPKernelApp.launch_instance(kernel_class=AnsibleKernel)
'data': { "text/plain": err, }, 'metadata': {}, } self.send_response(self.iopub_socket, 'display_data', display_data) else: display_data = { 'data': { "text/html": output, }, 'metadata': {}, } self.send_response(self.iopub_socket, 'display_data', display_data) temp.close() return { 'status': 'ok', # The base class increments the execution count 'execution_count': self.execution_count, 'payload': [], 'user_expressions': {}, } if __name__ == '__main__': from ipykernel.kernelapp import IPKernelApp IPKernelApp.launch_instance(kernel_class=CbshKernel)
def do_execute(self, code, silent, store_history=True, user_expressions=None, allow_stdin=False): if not silent: codelines = code.split('\n') for codeline in codelines: execution_result = self.execute_code(codeline) if execution_result: stream_content = { 'name': 'stdout', 'text': execution_result } self.send_response(self.iopub_socket, 'stream', stream_content) return { 'status': 'ok', 'execution_count': self.execution_count, 'payload': [], 'user_expressions': {}, } if __name__ == '__main__': from ipykernel.kernelapp import IPKernelApp IPKernelApp.launch_instance(kernel_class=ObjectScriptKernel)
from .idris2kernel import Idris2Kernel if __name__ == '__main__': from ipykernel.kernelapp import IPKernelApp IPKernelApp.launch_instance(kernel_class=Idris2Kernel)
p.write_contents() p.write_contents() if p.returncode != 0: self._write_to_stderr( "[SaC kernel] Executable exited with code {}".format( p.returncode)) else: if r["ret"] == 2: # stmts self.stmts.append(code) elif r["ret"] == 3: # funs self.funs.append(code) elif r["ret"] == 4: # use/import/typedef self.imports.append(code) return { 'status': 'ok', 'execution_count': self.execution_count, 'payload': [], 'user_expressions': {} } def do_shutdown(self, restart): """Cleanup the created source code files and executables when shutting down the kernel""" self.cleanup_files() if __name__ == "__main__": from ipykernel.kernelapp import IPKernelApp IPKernelApp.launch_instance(kernel_class=SacKernel)
response = {'name': 'stdout', 'text': hist.outs[-1]} self.send_response(self.iopub_socket, 'stream', response) if interrupted: return {'status': 'abort', 'execution_count': self.execution_count} rtn = 0 if len(hist) == 0 else hist.rtns[-1] if 0 < rtn: message = {'status': 'error', 'execution_count': self.execution_count, 'ename': '', 'evalue': str(rtn), 'traceback': []} else: message = {'status': 'ok', 'execution_count': self.execution_count, 'payload': [], 'user_expressions': {}} return message def do_complete(self, code, pos): """Get completions.""" shell = builtins.__xonsh_shell__ comps, beg, end = shell.completer.find_and_complete(code, pos, shell.ctx) message = {'matches': comps, 'cursor_start': beg, 'cursor_end': end+1, 'metadata': {}, 'status': 'ok'} return message if __name__ == '__main__': from ipykernel.kernelapp import IPKernelApp # must manually pass in args to avoid interfering w/ Jupyter arg parsing with main_context(argv=['--shell-type=readline']): IPKernelApp.launch_instance(kernel_class=XonshKernel)
from ipykernel.kernelapp import IPKernelApp from .kernel import QuonKernel IPKernelApp.launch_instance(kernel_class=QuonKernel)
from ipykernel.kernelapp import IPKernelApp from . import QtpiShort IPKernelApp.launch_instance(kernel_class=QtpiShort)
from ipykernel.kernelapp import IPKernelApp from .kernel import CQLKernel IPKernelApp.launch_instance(kernel_class=CQLKernel)
# Distributed under the terms of the Modified BSD License. from sparkmagic.utils.constants import LANG_R from sparkmagic.kernels.wrapperkernel.sparkkernelbase import SparkKernelBase class SparkRKernel(SparkKernelBase): def __init__(self, **kwargs): implementation = 'SparkR' implementation_version = '1.0' language = LANG_R language_version = '0.1' language_info = { 'name': 'sparkR', 'mimetype': 'text/x-rsrc', 'codemirror_mode': 'text/x-rsrc', 'file_extension': '.r', 'pygments_lexer': 'r' } session_language = LANG_R super(SparkRKernel, self).__init__(implementation, implementation_version, language, language_version, language_info, session_language, **kwargs) if __name__ == '__main__': from ipykernel.kernelapp import IPKernelApp IPKernelApp.launch_instance(kernel_class=SparkRKernel)
try: with pipes(stdout=_PseudoStream(partial(self.Print, end="")), stderr=_PseudoStream(partial(self.Error, end=""))): future = self._matlab.eval(code, nargout=0, async=True) future.result() except (SyntaxError, MatlabExecutionError, KeyboardInterrupt) as exc: stdout = exc.args[0] return ExceptionWrapper("Error", -1, stdout) def _execute_sync(self, code): out = StringIO() err = StringIO() if not isinstance(code, str): code = code.encode('utf8') try: self._matlab.eval(code, nargout=0, stdout=out, stderr=err) except (SyntaxError, MatlabExecutionError) as exc: stdout = exc.args[0] self.Error(stdout) return ExceptionWrapper("Error", -1, stdout) stdout = out.getvalue() self.Print(stdout) if __name__ == '__main__': try: from ipykernel.kernelapp import IPKernelApp except ImportError: from IPython.kernel.zmq.kernelapp import IPKernelApp IPKernelApp.launch_instance(kernel_class=MatlabKernel)
from ipykernel.kernelapp import IPKernelApp from .kernel import YottaDBKernel IPKernelApp.launch_instance(kernel_class=YottaDBKernel)