Commit 57c8c618 authored by Yusei Tahara's avatar Yusei Tahara

erp5_data_notebook: If wrong setup method was added, then remove it otherwise...

erp5_data_notebook: If wrong setup method was added, then remove it otherwise jupyter becomes permanent unusable state.
parent 3841bde5
......@@ -388,6 +388,7 @@ def Base_runJupyterCode(self, jupyter_code, old_notebook_context):
del notebook_context['setup'][key]
# Running all the setup functions that we got
failed_setup_key_list = []
for key, value in notebook_context['setup'].iteritems():
try:
code = compile(value['code'], '<string>', 'exec')
......@@ -395,12 +396,15 @@ def Base_runJupyterCode(self, jupyter_code, old_notebook_context):
# An error happened, so we show the user the stacktrace along with a
# note that the exception happened in a setup function's code.
except Exception as e:
failed_setup_key_list.append(key)
if value['func_name'] in user_context:
del user_context[value['func_name']]
error_return_dict = getErrorMessageForException(self, e, notebook_context)
additional_information = "An error happened when trying to run the one of your setup functions:"
error_return_dict['traceback'].insert(0, additional_information)
setup_error_return_dict_list.append(error_return_dict)
for failed_setup_key in failed_setup_key_list:
del notebook_context['setup'][failed_setup_key]
# Iterating over envinronment.define calls captured by the environment collector
# that are functions and saving them as setup functions.
......
......@@ -46,13 +46,13 @@
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple>
<string>W:394, 10: Use of exec (exec-used)</string>
<string>W:437, 10: Use of exec (exec-used)</string>
<string>W:450, 10: Use of exec (exec-used)</string>
<string>W:539, 4: No exception type(s) specified (bare-except)</string>
<string>W:547, 6: No exception type(s) specified (bare-except)</string>
<string>W:859, 6: Use of exec (exec-used)</string>
<string>W:1094, 2: Redefining name \'IFrame\' from outer scope (line 4) (redefined-outer-name)</string>
<string>W:395, 10: Use of exec (exec-used)</string>
<string>W:441, 10: Use of exec (exec-used)</string>
<string>W:454, 10: Use of exec (exec-used)</string>
<string>W:543, 4: No exception type(s) specified (bare-except)</string>
<string>W:551, 6: No exception type(s) specified (bare-except)</string>
<string>W:863, 6: Use of exec (exec-used)</string>
<string>W:1098, 2: Redefining name \'IFrame\' from outer scope (line 4) (redefined-outer-name)</string>
</tuple>
</value>
</item>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment