Commit 242800cf authored by Jérome Perrin's avatar Jérome Perrin

fixup! ERP5 py3: WIP ( all changes squashed )

parent f039bbd1
Pipeline #34263 failed with stage
in 0 seconds
......@@ -11,7 +11,7 @@ parts =
<= numpy-env
[ipython]
recipe = zc.recipe.egg:custom
recipe = zc.recipe.egg
egg = ipython
environment = ipython-env
setup-eggs =
......
......@@ -15,11 +15,11 @@
[instance-jupyter-notebook]
filename = instance.cfg.in
md5sum = fd7ed44da8d8723983b8666df2971a36
md5sum = 8760f6cbc16277f09cc575ad87bdd25b
[jupyter-notebook-config]
filename = jupyter_notebook_config.py.jinja
md5sum = 9d579353b579b6e488ae6330c7f4ad68
md5sum = 5ee1e68ccdac3e5424709e9569b49e09
[jupyter-set-password]
filename = jupyter_set_password.cgi.jinja
......
......@@ -74,10 +74,13 @@ environment =
[jupyter-notebook-config]
recipe = slapos.recipe.template:jinja2
url = {{ jupyter_config_location }}/{{ jupyter_config_filename }}
output = ${directory:jupyter_config_dir}/jupyter_notebook_config.py
output = ${directory:jupyter_config_dir}/jupyter_server_config.py
context =
raw config_cfg ${buildout:directory}/knowledge0.cfg
[jupyter-notebook-config:python2]
output = ${directory:jupyter_config_dir}/jupyter_notebook_config.py
[directory]
recipe = slapos.cookbook:mkdirectory
home = ${buildout:directory}
......@@ -100,7 +103,7 @@ erp5_kernel_dir = ${:jupyter_kernel_dir}/ERP5
# This part is called like this because knowledge0.write uses the part name for
# the section name in the config file.
recipe = slapos.cookbook:zero-knowledge.write
password =
password =
filename = knowledge0.cfg
[read-knowledge0]
......@@ -136,7 +139,7 @@ output = ${directory:erp5_kernel_dir}/kernel.json
context =
raw python_executable {{ python_executable }}
raw kernel_dir ${erp5-kernel:target-directory}/{{ erp5_kernel_filename }}
key erp5_url slapconfiguration:configuration.erp5-url
key erp5_url slapconfiguration:configuration.erp5-url
raw display_name ERP5
raw language_name python
......
......@@ -2,9 +2,13 @@
This script initializes Jupyter's configuration such as passwords and other
things. It is run by IPython hence why it can use functions like get_config().
'''
import ConfigParser
import six
from six.moves.configparser import ConfigParser
import random
from notebook.auth import passwd
if six.PY3:
from jupyter_server.auth import passwd
else:
from notebook.auth import passwd
import os
import ssl
......@@ -17,8 +21,8 @@ def random_password(length = 10):
knowledge_0 = '{{ config_cfg }}'
if not os.path.exists(knowledge_0):
print "Your software does <b>not</b> embed 0-knowledge. \
This interface is useless in this case</body></html>"
print ("Your software does <b>not</b> embed 0-knowledge.\n"
"This interface is useless in this case</body></html>")
exit(0)
c = get_config()
......@@ -33,10 +37,16 @@ if not parser.has_option("jupyter_notebook", "password") or \
parser.get("jupyter_notebook", "password") == "":
parser.set("jupyter_notebook", "password", random_password())
c.NotebookApp.password = passwd(parser.get("jupyter_notebook", "password"))
c.NotebookApp.ssl_options = {
c.ServerApp.password = passwd(parser.get("jupyter_notebook", "password"))
c.ServerApp.ssl_options = {
'ssl_version': ssl.PROTOCOL_TLSv1_2,
}
if six.PY3:
import pathlib
import jupyterlab
c.LabApp.app_dir = str(pathlib.Path(jupyterlab.__file__).parent.parent / 'share' / 'jupyter' / 'lab')
with open(knowledge_0, 'w') as file:
parser.write(file)
......@@ -19,11 +19,11 @@ md5sum = 5f39952f94095b1f12f41db76867e71e
[instance-jupyter]
filename = instance-jupyter.cfg.in
md5sum = f9a0e5a134456d74ca8b4d87862f903d
md5sum = 1466a598280cecdff60c4f4b5866df9a
[jupyter-notebook-config]
filename = jupyter_notebook_config.py.jinja
md5sum = 089e4c511a3c7b110471bf41ca2695a4
md5sum = 601efe6ee4c9e2712d03981c0da870b0
[erp5-kernel]
filename = ERP5kernel.py
......
......@@ -91,7 +91,6 @@ environment =
[jupyter-password]
recipe = slapos.cookbook:generate.password
bytes = 10
[jupyter-notebook-config]
recipe = slapos.recipe.template:jinja2
......@@ -171,13 +170,11 @@ instance-configuration =
[publish-connection-parameter]
recipe = slapos.cookbook:publish
jupyter-classic-url = ${request-slave-frontend:connection-secure_access}/tree
url = ${:jupyter-classic-url}
jupyterlab-url = ${request-slave-frontend:connection-secure_access}/lab
url = ${:jupyterlab-url}
{% if additional_frontend %}
jupyter-classic-url-additional = ${request-slave-frontend-additional:connection-secure_access}/tree
url-additional = ${:jupyter-classic-url-additional}
jupyterlab-url-additional = ${request-slave-frontend-additional:connection-secure_access}/lab
url-additional = ${:jupyterlab-url-additional}
{% endif %}
password = ${jupyter-password:passwd}
......@@ -194,7 +191,7 @@ output = ${directory:erp5_kernel_dir}/kernel.json
context =
raw python_executable {{ python_executable }}
raw kernel_dir ${erp5-kernel:target-directory}/{{ erp5_kernel_filename }}
key erp5_url slapconfiguration:configuration.erp5-url
key erp5_url slapconfiguration:configuration.erp5-url
raw display_name ERP5
raw language_name python
......
......@@ -2,13 +2,15 @@
This script initializes Jupyter's configuration such as passwords and other
things. It is run by IPython hence why it can use functions like get_config().
'''
import configparser
from notebook.auth import passwd
from jupyter_server.auth import passwd
import pathlib
import jupyterlab
import os
c = get_config()
c.NotebookApp.password = passwd("{{ password }}")
c.ServerApp.password = passwd("{{ password }}")
c.LabApp.app_dir = str(pathlib.Path(jupyterlab.__file__).parent.parent / 'share' / 'jupyter' / 'lab')
try:
os.environ['PATH'] = "{{ gcc_location }}/bin" + os.pathsep + os.environ['PATH']
......
......@@ -52,10 +52,9 @@ class TestJupyter(InstanceTestCase):
self.assertEqual(
{
'jupyter-classic-url': 'https://[%s]:8888/tree' % (self.computer_partition_ipv6_address, ),
'jupyterlab-url': 'https://[%s]:8888/lab' % (self.computer_partition_ipv6_address, ),
'password': '%s' % (password, ),
'url': 'https://[%s]:8888/tree' % (self.computer_partition_ipv6_address, )
'url': 'https://[%s]:8888/lab' % (self.computer_partition_ipv6_address, )
},
connection_dict
)
......@@ -63,7 +62,7 @@ class TestJupyter(InstanceTestCase):
result = requests.get(
connection_dict['url'], verify=False, allow_redirects=False)
self.assertEqual(
[http.client.FOUND, True, '/login?next=%2Ftree'],
[http.client.FOUND, True, '/login?next=%2Flab%3F'],
[result.status_code, result.is_redirect, result.headers['Location']]
)
......@@ -71,15 +70,7 @@ class TestJupyter(InstanceTestCase):
connection_dict['jupyter-classic-url'],
verify=False, allow_redirects=False)
self.assertEqual(
[http.client.FOUND, True, '/login?next=%2Ftree'],
[result.status_code, result.is_redirect, result.headers['Location']]
)
result = requests.get(
connection_dict['jupyterlab-url'],
verify=False, allow_redirects=False)
self.assertEqual(
[http.client.FOUND, True, '/login?next=%2Flab'],
[http.client.FOUND, True, '/login?next=%2Flab%3F'],
[result.status_code, result.is_redirect, result.headers['Location']]
)
......@@ -98,15 +89,7 @@ class TestJupyterAdditional(InstanceTestCase):
result = requests.get(
connection_dict['url'], verify=False, allow_redirects=False)
self.assertEqual(
[http.client.FOUND, True, '/login?next=%2Ftree'],
[result.status_code, result.is_redirect, result.headers['Location']]
)
result = requests.get(
connection_dict['jupyter-classic-url'],
verify=False, allow_redirects=False)
self.assertEqual(
[http.client.FOUND, True, '/login?next=%2Ftree'],
[http.client.FOUND, True, '/login?next=%2Flab%3F'],
[result.status_code, result.is_redirect, result.headers['Location']]
)
......@@ -121,15 +104,7 @@ class TestJupyterAdditional(InstanceTestCase):
result = requests.get(
connection_dict['url-additional'], verify=False, allow_redirects=False)
self.assertEqual(
[http.client.FOUND, True, '/login?next=%2Ftree'],
[result.status_code, result.is_redirect, result.headers['Location']]
)
result = requests.get(
connection_dict['jupyter-classic-url-additional'],
verify=False, allow_redirects=False)
self.assertEqual(
[http.client.FOUND, True, '/login?next=%2Ftree'],
[http.client.FOUND, True, '/login?next=%2Flab%3F'],
[result.status_code, result.is_redirect, result.headers['Location']]
)
......@@ -137,7 +112,7 @@ class TestJupyterAdditional(InstanceTestCase):
connection_dict['jupyterlab-url-additional'],
verify=False, allow_redirects=False)
self.assertEqual(
[http.client.FOUND, True, '/login?next=%2Flab'],
[http.client.FOUND, True, '/login?next=%2Flab%3F'],
[result.status_code, result.is_redirect, result.headers['Location']]
)
......
......@@ -800,7 +800,6 @@ Zope = 5.9+SlapOSPatched003
# Pinned versions
alabaster = 0.7.12
APacheDEX = 2.0
arrow = 1.2.3
astroid = 3.1.0:whl
Beaker = 1.11.0
cloudpickle = 0.5.3
......@@ -815,7 +814,6 @@ facebook-sdk = 2.0.0
five.formlib = 1.0.4
five.localsitemanager = 4.0
fpconst = 0.7.2
fqdn = 1.5.1
google-api-core = 2.17.1
google-api-python-client = 2.118.0
google-auth = 2.28.1
......@@ -828,11 +826,9 @@ huBarcode = 1.0.0+SlapOSPatched001
imageio = 2.34.0
interval = 1.0.0+SlapOSPatched001
ipdb = 0.10.2
isoduration = 20.11.0
isort = 5.13.2
jdcal = 1.3
jsonpickle = 0.9.6
jsonpointer = 2.2
lazy-object-proxy = 1.10.0
logilab-common = 1.3.0
Mako = 1.1.4
......@@ -851,7 +847,6 @@ oic = 1.6.1
olefile = 0.44
ordered-set = 4.1.0
Pillow = 10.2.0+SlapOSPatched001
platformdirs = 4.2.0:whl
polib = 1.2.0
pprofile = 2.0.4
Products.BTreeFolder2 = 4.4+SlapOSPatched001
......@@ -894,7 +889,6 @@ PyWavelets = 1.4.0
qrcode = 5.3
Record = 4.1.0
responses = 0.10.6
rfc3339-validator = 0.1.4
rfc3987 = 1.3.8
rsa = 3.4.2
scikit-image = 0.19.3
......@@ -905,17 +899,14 @@ StructuredText = 2.11.1
suds = 0.4
suds-py3 = 1.4.5.0
tifffile = 2024.2.12
tomli = 2.0.1:whl
tomlkit = 0.12.4:whl
toolz = 0.9.0
typed-ast = 1.5.5
typing = 3.10.0.0
unidiff = 0.5.5
uri-template = 1.2.0
urlnorm = 1.1.4+SlapOSPatched001
uuid = 1.30
validictory = 1.1.0
webcolors = 1.12
wrapt = 1.16.0
WSGIProxy2 = 0.4.6
WSGIUtils = 0.7
......@@ -1039,7 +1030,6 @@ zope.globalrequest = 1.6
zope.hookable = 5.4
zope.i18n = 4.9.0
zope.i18nmessageid = 5.1.1
zope.interface = 5.5.2
zope.lifecycleevent = 4.4
zope.location = 4.3
zope.pagetemplate = 4.6.0
......@@ -1058,8 +1048,6 @@ zope.structuredtext = 4.4
zope.tal = 4.5
zope.tales = 5.2
zope.testbrowser = 5.6.1
zope.testing = 4.10
zope.testrunner = 5.6
zope.traversing = 4.4.1
zope.viewlet = 4.3
ZServer = 4.0.2
......@@ -231,12 +231,14 @@ jedi = 0.17.2
Jinja2 = 3.1.2:whl
joblib = 1.3.2:whl
json5 = 0.9.20:whl
jsonpointer = 2.2
jsonschema = 4.17.3:whl
jupyter = 1.0.0
jupyter-client = 8.6.1:whl
jupyter-console = 6.6.3:whl
jupyter-core = 5.7.1:whl
jupyter-events = 0.6.3:whl
isoduration = 20.11.0
jupyter-lsp = 2.2.3:whl
jupyter-server = 2.10.0:whl
jupyter-server-terminals = 0.5.2:whl
......@@ -245,6 +247,8 @@ jupyterlab-launcher = 0.13.1
jupyterlab-pygments = 0.3.0:whl
jupyterlab-server = 2.24.0:whl
jupyterlab-widgets = 3.0.10:whl
arrow = 1.2.3
fqdn = 1.5.1
lock-file = 2.0
lockfile = 0.12.2:whl
lsprotocol = 2023.0.0b1:whl
......@@ -259,7 +263,7 @@ more-itertools = 5.0.0
mpmath = 1.3.0
msgpack = 1.0.5
multidict = 6.0.4
nbclient = 0.5.1
nbclient = 0.10.0:whl
nbconvert = 6.5.4
nbformat = 5.9.2:whl
nest-asyncio = 1.5.6
......@@ -283,6 +287,7 @@ pickleshare = 0.7.4
pim-dm = 1.4.0nxd002
pkgconfig = 1.5.1
pkgutil-resolve-name = 1.3.10
platformdirs = 4.2.0:whl
plone.recipe.command = 1.1
pluggy = 0.13.1:whl
ply = 3.11
......@@ -320,6 +325,7 @@ qtpy = 2.4.1:whl
random2 = 1.0.1
regex = 2020.9.27
requests = 2.31.0
rfc3339-validator = 0.1.4
rfc3986-validator = 0.1.1:whl
rpdb = 0.1.5
rubygemsrecipe = 0.4.4
......@@ -356,6 +362,7 @@ terminado = 0.9.1
testpath = 0.4.4
threadpoolctl = 3.3.0:whl
tinycss2 = 1.2.1:whl
tomli = 2.0.1:whl
tornado = 6.4
traitlets = 5.14.1:whl
trio = 0.22.0
......@@ -364,9 +371,11 @@ typeguard = 3.0.2:whl
typing-extensions = 4.8.0:whl
tzlocal = 1.5.1
unicodecsv = 0.14.1
uri-template = 1.2.0
uritemplate = 4.1.1
urllib3 = 1.26.12
wcwidth = 0.2.5
webcolors = 1.12
webencodings = 0.5.1
websocket-client = 1.5.1
websockets = 10.4
......@@ -431,6 +440,7 @@ jupyterlab-pygments = 0.1.2
MarkupSafe = 1.0
mpmath = 1.0.0
msgpack = 0.6.2
nbclient = 0.5.1
notebook = 6.1.5
packaging = 16.8
prompt-toolkit = 3.0.19
......
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