mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
Merge pull request #389 from jtpio/post-install-hook
Add tljh_post_install hook
This commit is contained in:
@@ -40,3 +40,9 @@ def tljh_config_post_install(config):
|
|||||||
@hookimpl
|
@hookimpl
|
||||||
def tljh_custom_jupyterhub_config(c):
|
def tljh_custom_jupyterhub_config(c):
|
||||||
c.JupyterHub.authenticator_class = 'tmpauthenticator.TmpAuthenticator'
|
c.JupyterHub.authenticator_class = 'tmpauthenticator.TmpAuthenticator'
|
||||||
|
|
||||||
|
|
||||||
|
@hookimpl
|
||||||
|
def tljh_post_install():
|
||||||
|
with open('test_post_install', 'w') as f:
|
||||||
|
f.write('123456789')
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ def test_config_hook():
|
|||||||
|
|
||||||
assert data['simplest_plugin']['present']
|
assert data['simplest_plugin']['present']
|
||||||
|
|
||||||
|
|
||||||
def test_jupyterhub_config_hook():
|
def test_jupyterhub_config_hook():
|
||||||
"""
|
"""
|
||||||
Test that tmpauthenticator is enabled by our custom config plugin
|
Test that tmpauthenticator is enabled by our custom config plugin
|
||||||
@@ -61,3 +62,13 @@ def test_jupyterhub_config_hook():
|
|||||||
resp = requests.get('http://localhost/hub/tmplogin', allow_redirects=False)
|
resp = requests.get('http://localhost/hub/tmplogin', allow_redirects=False)
|
||||||
assert resp.status_code == 302
|
assert resp.status_code == 302
|
||||||
assert resp.headers['Location'] == '/hub/spawn'
|
assert resp.headers['Location'] == '/hub/spawn'
|
||||||
|
|
||||||
|
|
||||||
|
def test_post_install_hook():
|
||||||
|
"""
|
||||||
|
Test that the test_post_install file has the correct content
|
||||||
|
"""
|
||||||
|
with open("test_post_install") as f:
|
||||||
|
content = f.read()
|
||||||
|
|
||||||
|
assert content == "123456789"
|
||||||
|
|||||||
@@ -59,3 +59,13 @@ def tljh_config_post_install(config):
|
|||||||
overwrite anything the user might have explicitly set.
|
overwrite anything the user might have explicitly set.
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@hookspec
|
||||||
|
def tljh_post_install():
|
||||||
|
"""
|
||||||
|
Post install script to be executed after installation
|
||||||
|
and after all the other hooks.
|
||||||
|
|
||||||
|
This can be arbitrary Python code.
|
||||||
|
"""
|
||||||
|
pass
|
||||||
@@ -405,6 +405,9 @@ def run_plugin_actions(plugin_manager, plugins):
|
|||||||
))
|
))
|
||||||
conda.ensure_pip_packages(USER_ENV_PREFIX, user_pip_packages)
|
conda.ensure_pip_packages(USER_ENV_PREFIX, user_pip_packages)
|
||||||
|
|
||||||
|
# Custom post install actions
|
||||||
|
hook.tljh_post_install()
|
||||||
|
|
||||||
|
|
||||||
def ensure_config_yaml(plugin_manager):
|
def ensure_config_yaml(plugin_manager):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user