From 5ab4dab4079063e320c7b3ea23bcb18f13fca884 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20W=C3=B6lfel?= <klaus@nexedi.com> Date: Thu, 19 Apr 2018 17:04:17 +0000 Subject: [PATCH] jupyter: add adhoc configuration for jupyterconvert --- .../extension.erp5.JupyterConvert.py | 16 ++++++++++------ .../extension.erp5.JupyterConvert.xml | 5 +++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/bt5/erp5_data_notebook/ExtensionTemplateItem/portal_components/extension.erp5.JupyterConvert.py b/bt5/erp5_data_notebook/ExtensionTemplateItem/portal_components/extension.erp5.JupyterConvert.py index ed8eedf4d7..debb3df3ae 100644 --- a/bt5/erp5_data_notebook/ExtensionTemplateItem/portal_components/extension.erp5.JupyterConvert.py +++ b/bt5/erp5_data_notebook/ExtensionTemplateItem/portal_components/extension.erp5.JupyterConvert.py @@ -8,6 +8,10 @@ from xmlrpclib import ServerProxy from urllib import urlencode from urllib2 import urlopen +import os +os.environ['JUPYTER_CONFIG_DIR'] = "/srv/slapgrid/slappart5/srv/runner/instance/slappart10/ipython" +os.environ['IPYTHONDIR'] = "/srv/slapgrid/slappart5/srv/runner/instance/slappart10/ipython" + class PyMarkdownPreprocessor(Preprocessor): """ :mod:`nbconvert` Preprocessor for the python-markdown nbextension. @@ -47,12 +51,12 @@ class PyMarkdownPreprocessor(Preprocessor): cell.source, variables) return cell, resources -def to_html(self): +def to_html(self, **kw): notebook = nbformat.reads(self.getTextContent(), as_version=4) resources = {} notebook = \ - ExecutePreprocessor(kernel_name="erp5").preprocess(notebook, resources)[0] + ExecutePreprocessor(timeout=300, kernel_name="erp5").preprocess(notebook, resources)[0] notebook = PyMarkdownPreprocessor().preprocess(notebook, resources)[0] html_exporter = HTMLExporter() @@ -63,9 +67,9 @@ def to_html(self): return body def cloudoooConvertFile(self, data, source_mimetype, destination_mimetype, zip=False, refresh=False, conversion_kw=None): - url = 'https://softinst78992.host.vifib.net/erp5/ERP5Site_htmlToPdf' - data_dict = {'data' : b64encode(data)} - data_dict.update(**conversion_kw) - return urlopen(url=url, data=urlencode(data_dict)).read() + #url = 'https://softinst78992.host.vifib.net/erp5/ERP5Site_htmlToPdf' + #data_dict = {'data' : b64encode(data)} + #data_dict.update(**conversion_kw) + #return urlopen(url=url, data=urlencode(data_dict)).read() proxy = ServerProxy(self.getPortalObject().portal_preferences.getPreferredDocumentConversionServerUrl(), allow_none=True) return b64decode(proxy.convertFile(b64encode(data), source_mimetype, destination_mimetype, zip, refresh, conversion_kw or {})) diff --git a/bt5/erp5_data_notebook/ExtensionTemplateItem/portal_components/extension.erp5.JupyterConvert.xml b/bt5/erp5_data_notebook/ExtensionTemplateItem/portal_components/extension.erp5.JupyterConvert.xml index e58dbd7318..f6bc13b857 100644 --- a/bt5/erp5_data_notebook/ExtensionTemplateItem/portal_components/extension.erp5.JupyterConvert.xml +++ b/bt5/erp5_data_notebook/ExtensionTemplateItem/portal_components/extension.erp5.JupyterConvert.xml @@ -46,9 +46,10 @@ <key> <string>text_content_warning_message</string> </key> <value> <tuple> - <string>W: 65, 75: Redefining built-in \'zip\' (redefined-builtin)</string> - <string>W: 70, 2: Unreachable code (unreachable)</string> + <string>W: 69, 75: Redefining built-in \'zip\' (redefined-builtin)</string> <string>W: 2, 0: Unused import ssl (unused-import)</string> + <string>W: 8, 0: Unused urlencode imported from urllib (unused-import)</string> + <string>W: 9, 0: Unused urlopen imported from urllib2 (unused-import)</string> </tuple> </value> </item> -- 2.30.9