Merge pull request #389 from jtpio/post-install-hook

Add tljh_post_install hook
This commit is contained in:
Yuvi Panda
2019-07-02 16:29:38 -07:00
committed by GitHub
4 changed files with 31 additions and 1 deletions

View File

@@ -39,4 +39,10 @@ def tljh_config_post_install(config):
@hookimpl
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')

View File

@@ -54,6 +54,7 @@ def test_config_hook():
assert data['simplest_plugin']['present']
def test_jupyterhub_config_hook():
"""
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)
assert resp.status_code == 302
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"

View File

@@ -58,4 +58,14 @@ def tljh_config_post_install(config):
be the serialized contents of config, so try to not
overwrite anything the user might have explicitly set.
"""
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

View File

@@ -405,6 +405,9 @@ def run_plugin_actions(plugin_manager, plugins):
))
conda.ensure_pip_packages(USER_ENV_PREFIX, user_pip_packages)
# Custom post install actions
hook.tljh_post_install()
def ensure_config_yaml(plugin_manager):
"""