mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-07 10:04:07 +00:00
s/JupyterHubApp/JupyterHub/
users shouldn't need to know wtf Applications are
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
c = get_config()
|
||||
|
||||
# Add some users.
|
||||
c.JupyterHubApp.admin_users = {'rhea'}
|
||||
c.JupyterHub.admin_users = {'rhea'}
|
||||
c.Authenticator.whitelist = {'ganymede', 'io', 'rhea'}
|
||||
|
||||
# These environment variables are automatically supplied by the linked postgres
|
||||
@@ -11,7 +11,7 @@ c.Authenticator.whitelist = {'ganymede', 'io', 'rhea'}
|
||||
import os;
|
||||
pg_pass = os.getenv('POSTGRES_ENV_JPY_PSQL_PASSWORD')
|
||||
pg_host = os.getenv('POSTGRES_PORT_5432_TCP_ADDR')
|
||||
c.JupyterHubApp.db_url = 'postgresql://jupyterhub:{}@{}:5432/jupyterhub'.format(
|
||||
c.JupyterHub.db_url = 'postgresql://jupyterhub:{}@{}:5432/jupyterhub'.format(
|
||||
pg_pass,
|
||||
pg_host,
|
||||
)
|
||||
|
@@ -2,6 +2,6 @@
|
||||
|
||||
c = get_config()
|
||||
|
||||
c.JupyterHubApp.admin_users = {'rhea'}
|
||||
c.JupyterHub.admin_users = {'rhea'}
|
||||
c.LocalProcessSpawner.set_user = 'sudo'
|
||||
c.Authenticator.whitelist = {'ganymede', 'io', 'rhea'}
|
||||
|
@@ -55,32 +55,31 @@ from .spawner import Spawner, LocalProcessSpawner
|
||||
|
||||
aliases = {
|
||||
'log-level': 'Application.log_level',
|
||||
'f': 'JupyterHubApp.config_file',
|
||||
'base-url': 'JupyterHubApp.base_url',
|
||||
'config': 'JupyterHubApp.config_file',
|
||||
'y': 'JupyterHubApp.answer_yes',
|
||||
'ssl-key': 'JupyterHubApp.ssl_key',
|
||||
'ssl-cert': 'JupyterHubApp.ssl_cert',
|
||||
'ip': 'JupyterHubApp.ip',
|
||||
'port': 'JupyterHubApp.port',
|
||||
'db': 'JupyterHubApp.db_url',
|
||||
'pid-file': 'JupyterHubApp.pid_file',
|
||||
'f': 'JupyterHub.config_file',
|
||||
'base-url': 'JupyterHub.base_url',
|
||||
'config': 'JupyterHub.config_file',
|
||||
'y': 'JupyterHub.answer_yes',
|
||||
'ssl-key': 'JupyterHub.ssl_key',
|
||||
'ssl-cert': 'JupyterHub.ssl_cert',
|
||||
'ip': 'JupyterHub.ip',
|
||||
'port': 'JupyterHub.port',
|
||||
'db': 'JupyterHub.db_url',
|
||||
'pid-file': 'JupyterHub.pid_file',
|
||||
}
|
||||
|
||||
flags = {
|
||||
'debug': ({'Application' : {'log_level': logging.DEBUG}},
|
||||
"set log level to logging.DEBUG (maximize logging output)"),
|
||||
'generate-config': ({'JupyterHubApp': {'generate_config': True}},
|
||||
'generate-config': ({'JupyterHub': {'generate_config': True}},
|
||||
"generate default config file"),
|
||||
'no-db': ({'JupyterHubApp': {'db_url': 'sqlite:///:memory:'}},
|
||||
'no-db': ({'JupyterHub': {'db_url': 'sqlite:///:memory:'}},
|
||||
"disable persisting state database to disk"
|
||||
),
|
||||
}
|
||||
|
||||
SECRET_BYTES = 2048 # the number of bytes to use when generating new secrets
|
||||
|
||||
|
||||
class JupyterHubApp(Application):
|
||||
class JupyterHub(Application):
|
||||
"""An Application for starting a Multi-User Jupyter Notebook server."""
|
||||
name = 'jupyterhub'
|
||||
|
||||
@@ -182,7 +181,7 @@ class JupyterHubApp(Application):
|
||||
self.log.warn('\n'.join([
|
||||
"",
|
||||
"Generating CONFIGPROXY_AUTH_TOKEN. Restarting the Hub will require restarting the proxy.",
|
||||
"Set CONFIGPROXY_AUTH_TOKEN env or JupyterHubApp.proxy_auth_token config to avoid this message.",
|
||||
"Set CONFIGPROXY_AUTH_TOKEN env or JupyterHub.proxy_auth_token config to avoid this message.",
|
||||
"",
|
||||
]))
|
||||
token = orm.new_token()
|
||||
@@ -688,11 +687,17 @@ class JupyterHubApp(Application):
|
||||
|
||||
@catch_config_error
|
||||
def initialize(self, *args, **kwargs):
|
||||
super(JupyterHubApp, self).initialize(*args, **kwargs)
|
||||
super().initialize(*args, **kwargs)
|
||||
if self.generate_config:
|
||||
return
|
||||
self.load_config_file(self.config_file)
|
||||
self.init_logging()
|
||||
if 'JupyterHubApp' in self.config:
|
||||
self.log.warn("Use JupyterHub in config, not JupyterHubApp. Ignoring config:\n%s",
|
||||
'\n'.join('JupyterHubApp.{key} = {value!r}'.format(key=key, value=value)
|
||||
for key, value in self.config.JupyterHubApp.items()
|
||||
)
|
||||
)
|
||||
self.write_pid_file()
|
||||
self.init_ports()
|
||||
self.init_secrets()
|
||||
@@ -822,7 +827,7 @@ class JupyterHubApp(Application):
|
||||
# run the cleanup step (in a new loop, because the interrupted one is unclean)
|
||||
IOLoop().run_sync(self.cleanup)
|
||||
|
||||
main = JupyterHubApp.launch_instance
|
||||
main = JupyterHub.launch_instance
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
@@ -11,7 +11,7 @@ from tornado import ioloop
|
||||
|
||||
from .. import orm
|
||||
|
||||
from .mocking import MockHubApp
|
||||
from .mocking import MockHub
|
||||
|
||||
|
||||
# global db session object
|
||||
@@ -46,7 +46,7 @@ def io_loop():
|
||||
|
||||
@fixture(scope='module')
|
||||
def app(request):
|
||||
app = MockHubApp.instance(log_level=logging.DEBUG)
|
||||
app = MockHub.instance(log_level=logging.DEBUG)
|
||||
app.start([])
|
||||
request.addfinalizer(app.stop)
|
||||
return app
|
||||
|
@@ -9,7 +9,7 @@ from unittest import mock
|
||||
from tornado.ioloop import IOLoop
|
||||
|
||||
from ..spawner import LocalProcessSpawner
|
||||
from ..app import JupyterHubApp
|
||||
from ..app import JupyterHub
|
||||
from ..auth import PAMAuthenticator
|
||||
from .. import orm
|
||||
|
||||
@@ -50,8 +50,8 @@ class MockPAMAuthenticator(PAMAuthenticator):
|
||||
with mock.patch('simplepam.authenticate', mock_authenticate):
|
||||
return super(MockPAMAuthenticator, self).authenticate(*args, **kwargs)
|
||||
|
||||
class MockHubApp(JupyterHubApp):
|
||||
"""HubApp with various mock bits"""
|
||||
class MockHub(JupyterHub):
|
||||
"""Hub with various mock bits"""
|
||||
|
||||
db_file = None
|
||||
|
||||
@@ -74,14 +74,14 @@ class MockHubApp(JupyterHubApp):
|
||||
def _start():
|
||||
self.io_loop = IOLoop.current()
|
||||
# put initialize in start for SQLAlchemy threading reasons
|
||||
super(MockHubApp, self).initialize(argv=argv)
|
||||
super(MockHub, self).initialize(argv=argv)
|
||||
|
||||
# add an initial user
|
||||
user = orm.User(name='user')
|
||||
self.db.add(user)
|
||||
self.db.commit()
|
||||
self.io_loop.add_callback(evt.set)
|
||||
super(MockHubApp, self).start()
|
||||
super(MockHub, self).start()
|
||||
|
||||
self._thread = threading.Thread(target=_start)
|
||||
self._thread.start()
|
||||
|
@@ -1,4 +1,4 @@
|
||||
"""Test the JupyterHubApp entry point"""
|
||||
"""Test the JupyterHub entry point"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
@@ -8,7 +8,7 @@ from tempfile import NamedTemporaryFile
|
||||
def test_help_all():
|
||||
out = check_output([sys.executable, '-m', 'jupyterhub', '--help-all']).decode('utf8', 'replace')
|
||||
assert '--ip' in out
|
||||
assert '--JupyterHubApp.ip' in out
|
||||
assert '--JupyterHub.ip' in out
|
||||
|
||||
def test_generate_config():
|
||||
with NamedTemporaryFile(prefix='jupyterhub_config', suffix='.py') as tf:
|
||||
|
Reference in New Issue
Block a user