Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kwabena Antwi-Boasiako
slapos
Commits
c5fef63e
Commit
c5fef63e
authored
Feb 18, 2017
by
Yusei Tahara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Jupyter: Make the looks of ERP5 kernel more close to the normal python kernel's.
parent
eb6f94c1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
6 deletions
+18
-6
software/ipython_notebook/software.cfg
software/ipython_notebook/software.cfg
+1
-1
software/ipython_notebook/template/ERP5kernel.py.jinja
software/ipython_notebook/template/ERP5kernel.py.jinja
+17
-5
No files found.
software/ipython_notebook/software.cfg
View file @
c5fef63e
...
...
@@ -43,7 +43,7 @@ md5sum = d7d4a7e19d55bf14007819258bf42100
[erp5-kernel]
<= download-file-base
filename = ERP5kernel.py.jinja
md5sum =
24308ca010532863dbcf501f011f984
6
md5sum =
cbd35bbe54b66e9b2f73487ecdbc697
6
[kernel-json]
<= download-file-base
...
...
software/ipython_notebook/template/ERP5kernel.py.jinja
View file @
c5fef63e
...
...
@@ -215,6 +215,8 @@ class ERP5Kernel(Kernel):
code = code.strip()
extra_data_list = []
print_result = {}
displayhook_result = {}
if code.startswith('%'):
# No need to try-catch here as its already been taken that the code
...
...
@@ -270,12 +272,17 @@ class ERP5Kernel(Kernel):
# "evalue": null,
# "traceback": null,
# "code_result": "",
# "mime_type": "text/plain"
# "print_result": {},
# "displayhook_result": {},
# "mime_type": "text/plain",
# "extra_data_list": []
# }
# So, we can easily use any of the key to update values as such.
# Getting code_result for succesfull execution of code
code_result = content['code_result']
print_result = content['print_result']
displayhook_result = content['displayhook_result']
# Update mime_type with the mime_type from the http response result
# Required in case the mime_type is anything other than 'text/plain'
...
...
@@ -297,21 +304,26 @@ class ERP5Kernel(Kernel):
except ValueError:
content = self.response
code_result = content
print_result = {'data':{'text/plain':content}, 'metadata':{}}
# Display basic error message to frontend in case of error on server side
else:
self.make_erp5_request(code=code)
code_result = "Error at Server Side"
print_result = {'data':{'text/plain':'Error at Server Side'}, 'metadata':{}}
mime_type = 'text/plain'
# For all status_code except allowed_HTTP_response_code_list show unauthorized message
else:
code_result = 'Unauthorized access'
print_result = {'data':{'text/plain':'Unauthorized access'}, 'metadata':{}}
mime_type = 'text/plain'
data = {
'data': {mime_type: code_result},
'metadata': {}}
self.send_response(self.iopub_socket, 'display_data', data)
if print_result.get('data'):
self.send_response(self.iopub_socket, 'display_data', print_result)
if displayhook_result.get('data'):
displayhook_result['execution_count'] = self.execution_count
self.send_response(self.iopub_socket, 'execute_result', displayhook_result)
for extra_data in extra_data_list:
self.send_response(self.iopub_socket, 'display_data', extra_data)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment