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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Douglas
erp5
Commits
073e5d55
Commit
073e5d55
authored
Nov 22, 2015
by
Ayush Tiwari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_data_notebook bt5: Add external method to display error from error_log
parent
d02f40c9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
9 deletions
+65
-9
bt5/erp5_data_notebook/ExtensionTemplateItem/portal_components/extension.erp5.JupyterCompile.py
...teItem/portal_components/extension.erp5.JupyterCompile.py
+31
-4
bt5/erp5_data_notebook/ExtensionTemplateItem/portal_components/extension.erp5.JupyterCompile.xml
...eItem/portal_components/extension.erp5.JupyterCompile.xml
+6
-5
bt5/erp5_data_notebook/SkinTemplateItem/portal_skins/erp5_data_notebook/getError.xml
...TemplateItem/portal_skins/erp5_data_notebook/getError.xml
+28
-0
No files found.
bt5/erp5_data_notebook/ExtensionTemplateItem/portal_components/extension.erp5.JupyterCompile.py
View file @
073e5d55
...
...
@@ -9,6 +9,9 @@ import ast
import
types
mime_type
=
'text/plain'
# IPython expects 2 status message - 'ok', 'error'
status
=
u'ok'
ename
,
evalue
,
tb_list
=
None
,
None
,
None
def
Base_compileJupyterCode
(
self
,
jupyter_code
,
old_local_variable_dict
):
"""
...
...
@@ -47,8 +50,11 @@ def Base_compileJupyterCode(self, jupyter_code, old_local_variable_dict):
# Updating global variable mime_type to its original value
# Required when call to Base_displayImage is made which is changing
# the value of gloabl mime_type
global
mime_type
# Same for status, ename, evalue, tb_list
global
mime_type
,
status
,
ename
,
evalue
,
tb_list
mime_type
=
'text/plain'
status
=
u'ok'
ename
,
evalue
,
tb_list
=
None
,
None
,
None
# Other way would be to use all the globals variables instead of just an empty
# dictionary, but that might hamper the speed of exec or eval.
...
...
@@ -59,16 +65,13 @@ def Base_compileJupyterCode(self, jupyter_code, old_local_variable_dict):
globals_dict
=
globals
()
g
[
'context'
]
=
self
result_string
=
''
ename
,
evalue
,
tb_list
=
None
,
None
,
None
# Update globals dict and use it while running exec command
g
.
update
(
old_local_variable_dict
[
'variables'
])
# IPython expects 2 status message - 'ok', 'error'
# XXX: The focus is on 'ok' status only, we're letting errors to be raised on
# erp5 for now, so as not to hinder the transactions while catching them.
# TODO: This can be refactored by using client side error handling instead of
# catching errors on server/erp5.
status
=
u'ok'
local_variable_dict
=
old_local_variable_dict
# Execute only if jupyter_code is not empty
...
...
@@ -294,3 +297,27 @@ def Base_saveImage(self, plot=None, reference=None, **kw):
filename
=
filename
)
return
None
def
getError
(
self
,
previous
=
1
):
"""
Show error to the frontend and change status of code as 'error' from 'ok'
Parameters
----------
previous: Type - int. The number of the error you want to see.
Ex: 1 for last error
2 for 2nd last error and so on..
"""
error_log_list
=
self
.
error_log
.
_getLog
()
if
error_log_list
:
if
isinstance
(
previous
,
int
):
# We need to get the object for last index of list
error
=
error_log_list
[
-
previous
]
global
status
,
ename
,
evalue
,
tb_list
status
=
u'error'
ename
=
unicode
(
error
[
'type'
])
evalue
=
unicode
(
error
[
'value'
])
tb_list
=
[
l
+
'
\
n
'
for
l
in
error
[
'tb_text'
].
split
(
'
\
n
'
)]
return
None
bt5/erp5_data_notebook/ExtensionTemplateItem/portal_components/extension.erp5.JupyterCompile.xml
View file @
073e5d55
...
...
@@ -46,11 +46,12 @@
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<tuple>
<string>
W: 50, 2: Using the global statement (global-statement)
</string>
<string>
W: 91, 8: Use of exec (exec-used)
</string>
<string>
W:115, 8: Use of exec (exec-used)
</string>
<string>
W:121, 8: Use of exec (exec-used)
</string>
<string>
W:216, 4: Using the global statement (global-statement)
</string>
<string>
W: 54, 2: Using the global statement (global-statement)
</string>
<string>
W: 94, 8: Use of exec (exec-used)
</string>
<string>
W:118, 8: Use of exec (exec-used)
</string>
<string>
W:124, 8: Use of exec (exec-used)
</string>
<string>
W:219, 4: Using the global statement (global-statement)
</string>
<string>
W:317, 2: Using the global statement (global-statement)
</string>
</tuple>
</value>
</item>
...
...
bt5/erp5_data_notebook/SkinTemplateItem/portal_skins/erp5_data_notebook/getError.xml
0 → 100644
View file @
073e5d55
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"ExternalMethod"
module=
"Products.ExternalMethod.ExternalMethod"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_function
</string>
</key>
<value>
<string>
getError
</string>
</value>
</item>
<item>
<key>
<string>
_module
</string>
</key>
<value>
<string>
JupyterCompile
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
getError
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
getError
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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