本文整理汇总了Python中ipykernel.kernelbase.Kernel类的典型用法代码示例。如果您正苦于以下问题:Python Kernel类的具体用法?Python Kernel怎么用?Python Kernel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Kernel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, **kwargs):
Kernel.__init__(self, **kwargs)
log('inside init')
# Catch KeyboardInterrupt, cancel query, raise QueryCancelledError
psycopg2.extensions.set_wait_callback(wait_select_inter)
self._conn_string = os.getenv('DATABASE_URL', '')
self._autocommit = True
self._conn = None
self._start_connection()
示例2: __init__
def __init__(self, **kwargs):
Kernel.__init__(self, **kwargs)
# The path to the unix micropython should be in the PATH, if not check
# the env for MPUNIX
#TODO: Use shutil.which() in python 3.3+
self.micropython_exe = 'micropython'
if os.environ.get('MPUNIX') is not None:
self.micropython_exe = os.environ.get('MPUNIX')
self._start_interpreter()
示例3: __init__
def __init__(self, **kwargs):
Kernel.__init__(self, **kwargs)
self._replace_get_ipython()
self.comm_manager = CommManager(shell=None, parent=self,
kernel=self)
self.shell_handlers['comm_open'] = self.comm_manager.comm_open
self.shell_handlers['comm_msg'] = self.comm_manager.comm_msg
self.shell_handlers['comm_close'] = self.comm_manager.comm_close
if ipywidgets_extension_loaded:
self.comm_manager.register_target('ipython.widget', Widget.handle_comm_opened)
self._start_polymake()
示例4: __init__
def __init__(self, **kwargs):
Kernel.__init__(self, **kwargs)
self._replace_get_ipython()
self.comm_manager = CommManager(shell=None, parent=self, kernel=self)
self.shell_handlers["comm_open"] = self.comm_manager.comm_open
self.shell_handlers["comm_msg"] = self.comm_manager.comm_msg
self.shell_handlers["comm_close"] = self.comm_manager.comm_close
self.comm_manager.register_target("ipython.widget", Widget.handle_comm_opened)
self._start_singular()
示例5: __init__
def __init__(self, **kwargs):
Kernel.__init__(self, **kwargs)
self._start_jython()
try:
self.hist_file = os.path.join(locate_profile(),'jython_kernel.hist')
except:
self.hist_file = None
self.log.warn('No default profile found, history unavailable')
self.max_hist_cache = 1000
self.hist_cache = []
示例6: __init__
def __init__(self, **kwargs):
self.mathjax_initialized = False
Kernel.__init__(self, **kwargs)
if self.log is None:
# This occurs if we call as a stand-alone kernel
# (eg, not as a process)
# FIXME: take care of input/output, eg StringIO
# make work without a session
self.log = logging.Logger("NotebookApp")
self.definitions = Definitions(add_builtin=True) # TODO Cache
self.definitions.set_ownvalue('$Line', Integer(0)) # Reset the line number
示例7: __init__
def __init__(self, **kwargs):
"""
Constructor
"""
Kernel.__init__(self, **kwargs);
opt = "";
if "LOG4J_CONF_FILE" in os.environ:
opt += " -4 " + os.environ["LOG4J_CONF_FILE"];
# Start grunt
self.pig = pexpect.spawn("/opt/pig-0.15.0/bin/pig -x local " + opt);
# Wait until grunt start
self.pig.expect(GRUNT_NEW_LINE_MODEL, timeout=GRUNT_START_TIMEOUT);
示例8: __init__
def __init__(self, **kwargs):
Kernel.__init__(self, **kwargs)
# powershell_command env variable is set by the kernel to allow both powershell and pwsh
# but on python2 we cannot pass it thru env variable, see https://github.com/vors/jupyter-powershell/issues/7
# TODO(python2): can we pass it somehow differently and still provide user-picked value on python2?
try:
powershell_command = environ['powershell_command']
except:
powershell_command = get_powershell()
repl = subprocess_repl.SubprocessRepl([powershell_command, '-noprofile', '-File', '-'])
self.proxy = powershell_proxy.ReplProxy(repl)
示例9: __init__
def __init__(self, **kwargs):
Kernel.__init__(self, **kwargs)
self._start_ncl()
try:
self.hist_file = os.path.join(locate_profile(),'ncl_kernel.hist')
except:
self.hist_file = None
self.log.warn('No default profile found, history unavailable')
self.max_hist_cache = 1000
self.hist_cache = []
#self._default_matches=cPickle.load(open('data/inbuilt_list', 'rb'))
self._default_matches=self.inbuiltlist()
示例10: __init__
def __init__(self, **kwargs):
Kernel.__init__(self, **kwargs)
# Instantiate IPython.core.debugger.Pdb here, pass it a phony
# stdout that provides a dummy flush() method and a write() method
# that internally sends data using a function so that it can
# be initialized to use self.send_response()
write_func = lambda s: self.send_response(self.iopub_socket,
'stream',
{'name': 'stdout',
'text': s})
sys.excepthook = functools.partial(BdbQuit_excepthook,
excepthook=sys.excepthook)
self.debugger = Pdb(stdout=PhonyStdout(write_func))
self.debugger.set_trace(sys._getframe().f_back)
示例11: __init__
def __init__(self, **kwargs):
Kernel.__init__(self, **kwargs)
ON_POSIX = 'posix' in sys.builtin_module_names
def enqueue_output(out, queue):
for line in iter(out.readline, b''):
queue.put(line)
out.close()
self._gforth = Popen('gforth', stdin=PIPE, stdout=PIPE, bufsize=2, close_fds=ON_POSIX)
self._gforth_queue = Queue()
t = Thread(target=enqueue_output, args=(self._gforth.stdout, self._gforth_queue))
t.daemon = True
t.start()
示例12: apply
def apply(self, expr, args, evaluation):
'Manipulate[expr_, args__]'
if (not _jupyter) or (not Kernel.initialized()) or (Kernel.instance() is None):
return evaluation.message('Manipulate', 'jupyter')
instantiator = _WidgetInstantiator() # knows about the arguments and their widgets
for arg in args.get_sequence():
try:
if not instantiator.add(arg, evaluation): # not a valid argument pattern?
return
except IllegalWidgetArguments as e:
return evaluation.message('Manipulate', 'widgetargs', strip_context(str(e.var)))
except JupyterWidgetError as e:
return evaluation.message('Manipulate', 'widgetmake', e.err)
clear_output_callback = evaluation.output.clear
display_data_callback = evaluation.output.display # for pushing updates
try:
clear_output_callback(wait=True)
except NotImplementedError:
return evaluation.message('Manipulate', 'imathics')
def callback(**kwargs):
clear_output_callback(wait=True)
line_no = evaluation.definitions.get_line_no()
vars = [Expression('Set', Symbol(name), value) for name, value in kwargs.items()]
evaluatable = Expression('ReleaseHold', Expression('Module', Expression('List', *vars), expr))
result = evaluation.evaluate(evaluatable, timeout=settings.TIMEOUT)
if result:
display_data_callback(data=result.result, metadata={})
evaluation.definitions.set_line_no(line_no) # do not increment line_no for manipulate computations
widgets = instantiator.get_widgets()
if len(widgets) > 0:
box = _interactive(instantiator.build_callback(callback), widgets) # create the widget
formatter = IPythonDisplayFormatter()
if not formatter(box): # make the widget appear on the Jupyter notebook
return evaluation.message('Manipulate', 'widgetdisp')
return Symbol('Null') # the interactive output is pushed via kernel.display_data_callback (see above)
示例13: __init__
def __init__(self, **kwargs):
Kernel.__init__(self, **kwargs)
self.repl = ReplWrapper()
示例14: __init__
def __init__(self, **kwargs):
Kernel.__init__(self, **kwargs)
self._start_magma()
示例15: __init__
def __init__(self, **kwargs):
Kernel.__init__(self, **kwargs)
self.tcl = Tkinter.Tcl()
self.execution_count = 0