mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
Move plugin manager to utils
Fix typo
This commit is contained in:
@@ -4,13 +4,12 @@ JupyterHub config for the littlest jupyterhub.
|
||||
|
||||
from glob import glob
|
||||
import os
|
||||
import pluggy
|
||||
|
||||
from systemdspawner import SystemdSpawner
|
||||
from tljh import configurer, user, hooks
|
||||
from tljh import configurer, user
|
||||
from tljh.config import INSTALL_PREFIX, USER_ENV_PREFIX, CONFIG_DIR
|
||||
from tljh.normalize import generate_system_username
|
||||
from tljh.yaml import yaml
|
||||
from tljh.utils import get_plugin_manager
|
||||
from jupyterhub_traefik_proxy import TraefikTomlProxy
|
||||
|
||||
from traitlets import Dict, Unicode, List
|
||||
@@ -68,11 +67,8 @@ configurer.apply_config(tljh_config, c)
|
||||
|
||||
# Let TLJH hooks modify `c` if they want
|
||||
|
||||
# Set up plugin infrastructure
|
||||
pm = pluggy.PluginManager('tljh')
|
||||
pm.add_hookspecs(hooks)
|
||||
pm.load_setuptools_entrypoints('tljh')
|
||||
# Call our custom configuration plugin
|
||||
pm = get_plugin_manager()
|
||||
pm.hook.tljh_custom_jupyterhub_config(c=c)
|
||||
|
||||
# Load arbitrary .py config files if they exist.
|
||||
|
||||
10
tljh/user.py
10
tljh/user.py
@@ -8,14 +8,8 @@ import pwd
|
||||
import subprocess
|
||||
from os.path import expanduser
|
||||
|
||||
import pluggy
|
||||
|
||||
from tljh import hooks
|
||||
|
||||
# Set up plugin infrastructure
|
||||
pm = pluggy.PluginManager('tljh')
|
||||
pm.add_hookspecs(hooks)
|
||||
pm.load_setuptools_entrypoints('tljh')
|
||||
from tljh.utils import get_plugin_manager
|
||||
|
||||
|
||||
def ensure_user(username):
|
||||
@@ -31,6 +25,8 @@ def ensure_user(username):
|
||||
# User doesn't exist, time to create!
|
||||
pass
|
||||
|
||||
pm = get_plugin_manager()
|
||||
|
||||
subprocess.check_call([
|
||||
'useradd',
|
||||
'--create-home',
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
"""
|
||||
Miscelaneous functions useful in at least two places unrelated to each other
|
||||
Miscellaneous functions useful in at least two places unrelated to each other
|
||||
"""
|
||||
import subprocess
|
||||
import logging
|
||||
|
||||
import subprocess
|
||||
|
||||
# Copied into bootstrap/bootstrap.py. Make sure these two copies are exactly the same!
|
||||
import pluggy
|
||||
|
||||
from tljh import hooks
|
||||
|
||||
|
||||
def run_subprocess(cmd, *args, **kwargs):
|
||||
"""
|
||||
Run given cmd with smart output behavior.
|
||||
@@ -33,4 +37,16 @@ def run_subprocess(cmd, *args, **kwargs):
|
||||
))
|
||||
# This produces multi line log output, unfortunately. Not sure how to fix.
|
||||
# For now, prioritizing human readability over machine readability.
|
||||
logger.debug(proc.stdout.decode())
|
||||
logger.debug(proc.stdout.decode())
|
||||
|
||||
|
||||
def get_plugin_manager():
|
||||
"""
|
||||
Return plugin manager instance
|
||||
"""
|
||||
# Set up plugin infrastructure
|
||||
pm = pluggy.PluginManager('tljh')
|
||||
pm.add_hookspecs(hooks)
|
||||
pm.load_setuptools_entrypoints('tljh')
|
||||
|
||||
return pm
|
||||
|
||||
Reference in New Issue
Block a user