Qudi
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
qzmqkernel.QZMQKernel Class Reference

A Qt-based embeddable kernel for Jupyter. More...

Inheritance diagram for qzmqkernel.QZMQKernel:
Inheritance graph
[legend]
Collaboration diagram for qzmqkernel.QZMQKernel:
Collaboration graph
[legend]

Public Member Functions

def __init__ (self, config=None)
 
def connect_kernel (self)
 
def init_exec_env (self)
 
def shutdown (self)
 
def msg_id (self)
 Return a new uuid for message id.
 
def sign (self, msg_lst)
 Sign a message with a secure signature.
 
def new_header (self, msg_type)
 make a new heade
 
def send (self, stream, msg_type, content=None, parent_header=None, metadata=None, identities=None)
 
def display_data (self, mimetype, fmt_dict, metadata=None)
 
def shell_handler (self, msg)
 
def shell_execute (self, identities, msg)
 
def shell_kernel_info (self, identities, msg)
 
def shell_history (self, identities, msg)
 
def shell_complete (self, identities, msg)
 
def deserialize_wire_msg (self, wire_msg)
 split the routing prefix and message frames from a message on the wire
 
def control_handler (self, wire_msg)
 
def iopub_handler (self, msg)
 
def stdin_handler (self, msg)
 
def bind (self, socket, connection, port)
 
def run_cell (self, raw_cell, store_history=False, silent=False, shell_futures=True)
 Run a complete IPython cell. More...
 
def transform_ast (self, node)
 Apply the AST transformations from self.ast_transformers. More...
 
def run_ast_nodes (self, nodelist, cell_name, interactivity='last_expr', compiler=compile, result=None)
 Run a sequence of AST nodes. More...
 
def run_code (self, code_obj, result=None)
 Execute a code object. More...
 
def excepthook (self, etype, value, tb)
 One more defense for GUI apps that call sys.excepthook. More...
 
def get_exception_only (self, exc_tuple=None)
 
def showtraceback (self, exc_tuple=None, filename=None, tb_offset=None, exception_only=False)
 Display the exception that just occurred. More...
 
def showsyntaxerror (self, filename=None)
 
def showindentationerror (self)
 

Public Attributes

 DELIM
 
 user_global_ns
 
 user_ns
 
 exiting
 
 engine_id
 
 config
 
 hb_thread
 
 connection
 
 secure_key
 
 signature_schemes
 
 auth
 
 ctx
 
 heartbeat_socket
 
 heartbeat_stream
 
 iopub_socket
 
 iopub_stream
 
 control_socket
 
 control_stream
 
 stdin_socket
 
 stdin_stream
 
 shell_socket
 
 shell_stream
 
 heartbeat_handler
 
 execution_count
 
 ast_node_interactivity
 
 compile
 
 events
 
 ast_transformers
 
 displaydata
 
 displayhook
 
 display_trap
 
 builtin_trap
 
 sys_excepthook
 

Static Public Attributes

 sigShutdownFinished = QtCore.Signal(str)
 
tuple supported_mime
 

Detailed Description

A Qt-based embeddable kernel for Jupyter.

Member Function Documentation

◆ excepthook()

def qzmqkernel.QZMQKernel.excepthook (   self,
  etype,
  value,
  tb 
)

One more defense for GUI apps that call sys.excepthook.

GUI frameworks like wxPython trap exceptions and call sys.excepthook themselves. I guess this is a feature that enables them to keep running after exceptions that would otherwise kill their mainloop. This is a bother for IPython which excepts to catch all of the program exceptions with a try: except statement. Normally, IPython sets sys.excepthook to a CrashHandler instance, so if any app directly invokes sys.excepthook, it will look to the user like IPython crashed. In order to work around this, we can disable the CrashHandler and replace it with this excepthook instead, which prints a regular traceback using our InteractiveTB. In this fashion, apps which call sys.excepthook will generate a regular-looking exception from IPython, and the CrashHandler will only be triggered by real IPython crashes. This hook should be used sparingly, only in places which are not likely to be true IPython errors.

◆ run_ast_nodes()

def qzmqkernel.QZMQKernel.run_ast_nodes (   self,
  nodelist,
  cell_name,
  interactivity = 'last_expr',
  compiler = compile,
  result = None 
)

Run a sequence of AST nodes.

The execution mode depends on the interactivity parameter.

Parameters

nodelist list A sequence of AST nodes to run. cell_name str Will be passed to the compiler as the filename of the cell. Typically the value returned by ip.compile.cache(cell). interactivity str 'all', 'last', 'last_expr' or 'none', specifying which nodes should be run interactively (displaying output from expressions). 'last_expr' will run the last node interactively only if it is an expression (i.e. expressions in loops or other blocks are not displayed. Other values for this parameter will raise a ValueError. compiler callable A function with the same interface as the built-in compile(), to turn the AST nodes into code objects. Default is the built-in compile(). result ExecutionResult, optional An object to store exceptions that occur during execution.

Returns

True if an exception occurred while running code, False if it finished running.

◆ run_cell()

def qzmqkernel.QZMQKernel.run_cell (   self,
  raw_cell,
  store_history = False,
  silent = False,
  shell_futures = True 
)

Run a complete IPython cell.

Parameters

raw_cell str The code (including IPython code such as magic functions) to run. store_history bool If True, the raw and translated cell will be stored in IPython's history. For user code calling back into IPython's machinery, this should be set to False. silent bool If True, avoid side-effects, such as implicit displayhooks and and logging. silent=True forces store_history=False. shell_futures bool If True, the code will share future statements with the interactive shell. It will both be affected by previous future imports, and any future imports in the code will affect the shell. If False, future imports are not shared in either direction.

Returns

result :class:ExecutionResult

◆ run_code()

def qzmqkernel.QZMQKernel.run_code (   self,
  code_obj,
  result = None 
)

Execute a code object.

When an exception occurs, self.showtraceback() is called to display a traceback.

Parameters

code_obj code object A compiled code object, to be executed result ExecutionResult, optional An object to store exceptions that occur during execution.

Returns

False successful execution. True an error occurred.

◆ showtraceback()

def qzmqkernel.QZMQKernel.showtraceback (   self,
  exc_tuple = None,
  filename = None,
  tb_offset = None,
  exception_only = False 
)

Display the exception that just occurred.

If nothing is known about the exception, this is the method which should be used throughout the code for presenting user tracebacks, rather than directly invoking the InteractiveTB object. A specific showsyntaxerror() also exists, but this method can take care of calling it if needed, so unless you are explicitly catching a SyntaxError exception, don't try to analyze the stack manually and simply call this method.

◆ transform_ast()

def qzmqkernel.QZMQKernel.transform_ast (   self,
  node 
)

Apply the AST transformations from self.ast_transformers.

Parameters

node ast.Node The root node to be transformed. Typically called with the ast.Module produced by parsing user input.

Returns

An ast.Node corresponding to the node it was called with. Note that it may also modify the passed object, so don't rely on references to the original AST.

Member Data Documentation

◆ supported_mime

tuple qzmqkernel.QZMQKernel.supported_mime
static
Initial value:
= (
'text/plain',
'text/html',
'text/markdown',
'text/latex',
'application/json',
'application/javascript',
'image/png',
'image/jpeg',
'image/svg+xml'
)

The documentation for this class was generated from the following file: