Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
139
Merge Requests
139
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
003e34c7
Commit
003e34c7
authored
Jan 21, 2017
by
Yusei Tahara
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Jupyter: Support displayhook.
parent
6b6f1fe0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
13 deletions
+29
-13
bt5/erp5_data_notebook/ExtensionTemplateItem/portal_components/extension.erp5.JupyterCompile.py
...teItem/portal_components/extension.erp5.JupyterCompile.py
+23
-7
bt5/erp5_data_notebook/ExtensionTemplateItem/portal_components/extension.erp5.JupyterCompile.xml
...eItem/portal_components/extension.erp5.JupyterCompile.xml
+6
-6
No files found.
bt5/erp5_data_notebook/ExtensionTemplateItem/portal_components/extension.erp5.JupyterCompile.py
View file @
003e34c7
...
...
@@ -170,18 +170,30 @@ def matplotlib_post_run(data_list):
metadata
=
{
'image/png'
:
dict
(
width
=
width
,
height
=
height
)}
data_list
.
append
(
json_clean
(
dict
(
data
=
data
,
metadata
=
metadata
)))
class
Displayhook
(
object
):
def
hook
(
self
,
value
):
self
.
result
=
repr
(
value
)
def
pre_run
(
self
):
self
.
old_hook
=
sys
.
displayhook
sys
.
displayhook
=
self
.
hook
self
.
result
=
''
def
post_run
(
self
):
sys
.
displayhook
=
self
.
old_hook
displayhook
=
Displayhook
()
def
displayDataWrapper
(
function
):
with
display_data_wrapper_lock
:
# pre run
displayhook
.
pre_run
()
matplotlib_pre_run
()
extra_data_list
=
[]
try
:
result
=
function
()
extra_data_list
=
result
.
get
(
'extra_data_list'
,
[])
finally
:
# post run
displayhook
.
post_run
()
matplotlib_post_run
(
extra_data_list
)
result
[
'extra_data_list'
]
=
extra_data_list
return
result
...
...
@@ -348,6 +360,8 @@ def Base_runJupyterCode(self, jupyter_code, old_notebook_context):
transaction
.
abort
()
result
=
{
'result_string'
:
"EnvironmentUndefineError: Trying to remove non existing function/variable from environment: '%s'
\
n
"
%
func_alias
,
'print_result'
:
"EnvironmentUndefineError: Trying to remove non existing function/variable from environment: '%s'
\
n
"
%
func_alias
,
'displayhook_result'
:
''
,
'notebook_context'
:
notebook_context
,
'status'
:
'ok'
,
'mime_type'
:
'text/plain'
,
...
...
@@ -463,6 +477,8 @@ def Base_runJupyterCode(self, jupyter_code, old_notebook_context):
result
=
{
'result_string'
:
output
,
'print_result'
:
output
,
'displayhook_result'
:
displayhook
.
result
,
'notebook_context'
:
notebook_context
,
'status'
:
status
,
'mime_type'
:
mime_type
,
...
...
bt5/erp5_data_notebook/ExtensionTemplateItem/portal_components/extension.erp5.JupyterCompile.xml
View file @
003e34c7
...
...
@@ -46,12 +46,12 @@
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<tuple>
<string>
W:3
69
, 10: Use of exec (exec-used)
</string>
<string>
W:4
12
, 10: Use of exec (exec-used)
</string>
<string>
W:4
25
, 10: Use of exec (exec-used)
</string>
<string>
W:5
10
, 6: No exception type(s) specified (bare-except)
</string>
<string>
W:7
63
, 6: Use of exec (exec-used)
</string>
<string>
W:
989
, 2: Redefining name \'IFrame\' from outer scope (line 4) (redefined-outer-name)
</string>
<string>
W:3
83
, 10: Use of exec (exec-used)
</string>
<string>
W:4
26
, 10: Use of exec (exec-used)
</string>
<string>
W:4
39
, 10: Use of exec (exec-used)
</string>
<string>
W:5
26
, 6: No exception type(s) specified (bare-except)
</string>
<string>
W:7
79
, 6: Use of exec (exec-used)
</string>
<string>
W:
1005
, 2: Redefining name \'IFrame\' from outer scope (line 4) (redefined-outer-name)
</string>
<string>
W: 18, 0: Unused log imported from Products.ERP5Type.Log (unused-import)
</string>
</tuple>
</value>
...
...
Yusei Tahara
@yusei
mentioned in commit
cf20478d
·
Jan 23, 2017
mentioned in commit
cf20478d
mentioned in commit cf20478d05f6dd91eb5f73e9619d545ee3a993bf
Toggle commit list
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