-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotkernel.py
35 lines (29 loc) · 1.1 KB
/
plotkernel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from ipykernel.kernelbase import Kernel
from pithon import compile_and_run
class PlotKernel(Kernel):
implementation = 'Plot'
implementation_version = '1.0'
language = 'python'
language_version = '3.6'
language_info = {'name': 'plotter',
'mimetype': 'text/plain',
'extension': '.py'}
banner = "Simple plotting"
def do_execute(self, code, silent,
store_history=True,
user_expressions=None,
allow_stdin=False):
if not silent:
result = compile_and_run(code)
stream_content = {'name': 'stdout', 'text': result}
self.send_response(self.iopub_socket, 'stream', stream_content)
# We return the exection results.
return {'status': 'ok',
'execution_count':
self.execution_count,
'payload': [],
'user_expressions': {},
}
if __name__ == '__main__':
from ipykernel.kernelapp import IPKernelApp
IPKernelApp.launch_instance(kernel_class=PlotKernel)