Commit 5ab4dab4 authored by Klaus Wölfel's avatar Klaus Wölfel

jupyter: add adhoc configuration for jupyterconvert

parent eb896b21
......@@ -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 {}))
......@@ -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>
......
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