mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
Merge pull request #893 from consideRatio/pr/add-pre-commit-isort-and-autoflake
pre-commit: add isort and autoflake
This commit is contained in:
4
.github/integration-test.py
vendored
4
.github/integration-test.py
vendored
@@ -1,9 +1,9 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import argparse
|
import argparse
|
||||||
from shutil import which
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
import os
|
from shutil import which
|
||||||
|
|
||||||
|
|
||||||
def container_runtime():
|
def container_runtime():
|
||||||
|
|||||||
@@ -20,6 +20,21 @@ repos:
|
|||||||
# exclude it from the pyupgrade hook that will apply f-strings etc.
|
# exclude it from the pyupgrade hook that will apply f-strings etc.
|
||||||
exclude: bootstrap/bootstrap.py
|
exclude: bootstrap/bootstrap.py
|
||||||
|
|
||||||
|
# Autoformat: Python code
|
||||||
|
- repo: https://github.com/PyCQA/autoflake
|
||||||
|
rev: v2.1.1
|
||||||
|
hooks:
|
||||||
|
- id: autoflake
|
||||||
|
# args ref: https://github.com/PyCQA/autoflake#advanced-usage
|
||||||
|
args:
|
||||||
|
- --in-place
|
||||||
|
|
||||||
|
# Autoformat: Python code
|
||||||
|
- repo: https://github.com/pycqa/isort
|
||||||
|
rev: 5.12.0
|
||||||
|
hooks:
|
||||||
|
- id: isort
|
||||||
|
|
||||||
# Autoformat: Python code
|
# Autoformat: Python code
|
||||||
- repo: https://github.com/psf/black
|
- repo: https://github.com/psf/black
|
||||||
rev: 23.3.0
|
rev: 23.3.0
|
||||||
|
|||||||
@@ -42,16 +42,16 @@ Command line flags, from "bootstrap.py --help":
|
|||||||
can also pass a branch name such as 'main' or a
|
can also pass a branch name such as 'main' or a
|
||||||
commit hash.
|
commit hash.
|
||||||
"""
|
"""
|
||||||
from argparse import ArgumentParser
|
import logging
|
||||||
import os
|
|
||||||
from http.server import SimpleHTTPRequestHandler, HTTPServer
|
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import logging
|
|
||||||
import shutil
|
|
||||||
import urllib.request
|
import urllib.request
|
||||||
|
from argparse import ArgumentParser
|
||||||
|
from http.server import HTTPServer, SimpleHTTPRequestHandler
|
||||||
|
|
||||||
progress_page_favicon_url = "https://raw.githubusercontent.com/jupyterhub/jupyterhub/main/share/jupyterhub/static/favicon.ico"
|
progress_page_favicon_url = "https://raw.githubusercontent.com/jupyterhub/jupyterhub/main/share/jupyterhub/static/favicon.ico"
|
||||||
progress_page_html = """
|
progress_page_html = """
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
#
|
#
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
|
||||||
# -- Project information -----------------------------------------------------
|
# -- Project information -----------------------------------------------------
|
||||||
# ref: https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
|
# ref: https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
from hubtraf.user import User
|
|
||||||
from hubtraf.auth.dummy import login_dummy
|
|
||||||
import pytest
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from hubtraf.auth.dummy import login_dummy
|
||||||
|
from hubtraf.user import User
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_admin_login():
|
async def test_admin_login():
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ def verify_progress_page(expected_status_code, timeout):
|
|||||||
if b"HTTP/1.0 200 OK" in resp:
|
if b"HTTP/1.0 200 OK" in resp:
|
||||||
progress_page_status = True
|
progress_page_status = True
|
||||||
break
|
break
|
||||||
except Exception as e:
|
except Exception:
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
import requests
|
|
||||||
from hubtraf.user import User
|
|
||||||
from hubtraf.auth.dummy import login_dummy
|
|
||||||
from jupyterhub.utils import exponential_backoff
|
|
||||||
import secrets
|
|
||||||
import pytest
|
|
||||||
from functools import partial
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import pwd
|
|
||||||
import grp
|
import grp
|
||||||
|
import pwd
|
||||||
|
import secrets
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from functools import partial
|
||||||
from os import system
|
from os import system
|
||||||
from tljh.normalize import generate_system_username
|
|
||||||
|
import pytest
|
||||||
|
import requests
|
||||||
|
from hubtraf.auth.dummy import login_dummy
|
||||||
|
from hubtraf.user import User
|
||||||
|
from jupyterhub.utils import exponential_backoff
|
||||||
from packaging.version import Version as V
|
from packaging.version import Version as V
|
||||||
|
|
||||||
|
from tljh.normalize import generate_system_username
|
||||||
|
|
||||||
# Use sudo to invoke it, since this is how users invoke it.
|
# Use sudo to invoke it, since this is how users invoke it.
|
||||||
# This catches issues with PATH
|
# This catches issues with PATH
|
||||||
TLJH_CONFIG_PATH = ["sudo", "tljh-config"]
|
TLJH_CONFIG_PATH = ["sudo", "tljh-config"]
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
from contextlib import contextmanager
|
|
||||||
from concurrent.futures import ProcessPoolExecutor
|
|
||||||
from functools import partial
|
|
||||||
import grp
|
import grp
|
||||||
import os
|
import os
|
||||||
import pwd
|
import pwd
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
from concurrent.futures import ProcessPoolExecutor
|
||||||
|
from contextlib import contextmanager
|
||||||
|
from functools import partial
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
ADMIN_GROUP = "jupyterhub-admins"
|
ADMIN_GROUP = "jupyterhub-admins"
|
||||||
USER_GROUP = "jupyterhub-users"
|
USER_GROUP = "jupyterhub-users"
|
||||||
INSTALL_PREFIX = os.environ.get("TLJH_INSTALL_PREFIX", "/opt/tljh")
|
INSTALL_PREFIX = os.environ.get("TLJH_INSTALL_PREFIX", "/opt/tljh")
|
||||||
@@ -93,7 +92,6 @@ def permissions_test(group, path, *, readable=None, writable=None, dirs_only=Fal
|
|||||||
# check if the path should be writable
|
# check if the path should be writable
|
||||||
if writable is not None:
|
if writable is not None:
|
||||||
if access(path, os.W_OK) != writable:
|
if access(path, os.W_OK) != writable:
|
||||||
stat = os.stat(path)
|
|
||||||
info = pool.submit(debug_uid_gid).result()
|
info = pool.submit(debug_uid_gid).result()
|
||||||
failures.append(
|
failures.append(
|
||||||
"{} {} should {}be writable by {} [{}]".format(
|
"{} {} should {}be writable by {} [{}]".format(
|
||||||
@@ -104,7 +102,6 @@ def permissions_test(group, path, *, readable=None, writable=None, dirs_only=Fal
|
|||||||
# check if the path should be readable
|
# check if the path should be readable
|
||||||
if readable is not None:
|
if readable is not None:
|
||||||
if access(path, os.R_OK) != readable:
|
if access(path, os.R_OK) != readable:
|
||||||
stat = os.stat(path)
|
|
||||||
info = pool.submit(debug_uid_gid).result()
|
info = pool.submit(debug_uid_gid).result()
|
||||||
failures.append(
|
failures.append(
|
||||||
"{} {} should {}be readable by {} [{}]".format(
|
"{} {} should {}be readable by {} [{}]".format(
|
||||||
|
|||||||
@@ -2,19 +2,19 @@
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import ssl
|
import ssl
|
||||||
from subprocess import check_call
|
|
||||||
import time
|
import time
|
||||||
|
from subprocess import check_call
|
||||||
|
|
||||||
import toml
|
|
||||||
from tornado.httpclient import HTTPClient, HTTPRequest, HTTPClientError
|
|
||||||
import pytest
|
import pytest
|
||||||
|
import toml
|
||||||
|
from tornado.httpclient import HTTPClient, HTTPClientError, HTTPRequest
|
||||||
|
|
||||||
from tljh.config import (
|
from tljh.config import (
|
||||||
|
CONFIG_DIR,
|
||||||
|
CONFIG_FILE,
|
||||||
|
STATE_DIR,
|
||||||
reload_component,
|
reload_component,
|
||||||
set_config_value,
|
set_config_value,
|
||||||
CONFIG_FILE,
|
|
||||||
CONFIG_DIR,
|
|
||||||
STATE_DIR,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -36,7 +36,6 @@ def send_request(url, max_sleep, validate_cert=True, username=None, password=Non
|
|||||||
break
|
break
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
pass
|
|
||||||
|
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
@@ -134,7 +133,7 @@ def test_extra_traefik_config():
|
|||||||
HTTPClient().fetch(req)
|
HTTPClient().fetch(req)
|
||||||
success = True
|
success = True
|
||||||
break
|
break
|
||||||
except Exception as e:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
assert success == True
|
assert success == True
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
"""
|
"""
|
||||||
Test simplest plugin
|
Test simplest plugin
|
||||||
"""
|
"""
|
||||||
from ruamel.yaml import YAML
|
|
||||||
import requests
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from tljh.config import CONFIG_FILE, USER_ENV_PREFIX, HUB_ENV_PREFIX
|
import requests
|
||||||
|
from ruamel.yaml import YAML
|
||||||
|
|
||||||
from tljh import user
|
from tljh import user
|
||||||
|
from tljh.config import CONFIG_FILE, HUB_ENV_PREFIX, USER_ENV_PREFIX
|
||||||
|
|
||||||
yaml = YAML(typ="rt")
|
yaml = YAML(typ="rt")
|
||||||
|
|
||||||
|
|||||||
34
pyproject.toml
Normal file
34
pyproject.toml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# autoflake is used for autoformatting Python code
|
||||||
|
#
|
||||||
|
# ref: https://github.com/PyCQA/autoflake#readme
|
||||||
|
#
|
||||||
|
[tool.autoflake]
|
||||||
|
ignore-init-module-imports = true
|
||||||
|
remove-all-unused-imports = true
|
||||||
|
remove-duplicate-keys = true
|
||||||
|
remove-unused-variables = true
|
||||||
|
|
||||||
|
|
||||||
|
# isort is used for autoformatting Python code
|
||||||
|
#
|
||||||
|
# ref: https://pycqa.github.io/isort/
|
||||||
|
#
|
||||||
|
[tool.isort]
|
||||||
|
profile = "black"
|
||||||
|
|
||||||
|
|
||||||
|
# black is used for autoformatting Python code
|
||||||
|
#
|
||||||
|
# ref: https://black.readthedocs.io/en/stable/
|
||||||
|
#
|
||||||
|
[tool.black]
|
||||||
|
# target-version should be all supported versions, see
|
||||||
|
# https://github.com/psf/black/issues/751#issuecomment-473066811
|
||||||
|
target_version = [
|
||||||
|
"py36",
|
||||||
|
"py37",
|
||||||
|
"py38",
|
||||||
|
"py39",
|
||||||
|
"py310",
|
||||||
|
"py311",
|
||||||
|
]
|
||||||
2
setup.py
2
setup.py
@@ -1,4 +1,4 @@
|
|||||||
from setuptools import setup, find_packages
|
from setuptools import find_packages, setup
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="the-littlest-jupyterhub",
|
name="the-littlest-jupyterhub",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"""pytest fixtures"""
|
"""pytest fixtures"""
|
||||||
from importlib import reload
|
|
||||||
import os
|
import os
|
||||||
import types
|
import types
|
||||||
|
from importlib import reload
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|||||||
@@ -5,9 +5,10 @@ import sys
|
|||||||
|
|
||||||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
||||||
|
|
||||||
from bootstrap import bootstrap
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from bootstrap import bootstrap
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"requested,expected",
|
"requested,expected",
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
"""
|
"""
|
||||||
Test conda commandline wrappers
|
Test conda commandline wrappers
|
||||||
"""
|
"""
|
||||||
from tljh import conda
|
|
||||||
from tljh import installer
|
|
||||||
import os
|
import os
|
||||||
import pytest
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from tljh import conda, installer
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
@pytest.fixture(scope="module")
|
||||||
def prefix():
|
def prefix():
|
||||||
"""
|
"""
|
||||||
Provide a temporary directory with a mambaforge conda environment
|
Provide a temporary directory with a mambaforge conda environment
|
||||||
"""
|
"""
|
||||||
machine = os.uname().machine
|
|
||||||
installer_url, checksum = installer._mambaforge_url()
|
installer_url, checksum = installer._mambaforge_url()
|
||||||
with tempfile.TemporaryDirectory() as tmpdir:
|
with tempfile.TemporaryDirectory() as tmpdir:
|
||||||
with conda.download_miniconda_installer(
|
with conda.download_miniconda_installer(
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ def test_set_overwrite():
|
|||||||
def test_unset_no_mutate():
|
def test_unset_no_mutate():
|
||||||
conf = {"a": "b"}
|
conf = {"a": "b"}
|
||||||
|
|
||||||
new_conf = config.unset_item_from_config(conf, "a")
|
config.unset_item_from_config(conf, "a")
|
||||||
assert conf == {"a": "b"}
|
assert conf == {"a": "b"}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,11 @@
|
|||||||
Test configurer
|
Test configurer
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from traitlets.config import Config
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from traitlets.config import Config
|
||||||
|
|
||||||
from tljh import configurer
|
from tljh import configurer
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,15 +3,14 @@ Unit test functions in installer.py
|
|||||||
"""
|
"""
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
from subprocess import PIPE, run
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
from subprocess import run, PIPE
|
|
||||||
|
|
||||||
from packaging.version import parse as V
|
|
||||||
from packaging.specifiers import SpecifierSet
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from packaging.specifiers import SpecifierSet
|
||||||
|
from packaging.version import parse as V
|
||||||
|
|
||||||
from tljh import conda
|
from tljh import conda, installer
|
||||||
from tljh import installer
|
|
||||||
from tljh.yaml import yaml
|
from tljh.yaml import yaml
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ Unit test functions in installer.py
|
|||||||
import os
|
import os
|
||||||
from datetime import date
|
from datetime import date
|
||||||
|
|
||||||
from tljh import migrator, config
|
from tljh import config, migrator
|
||||||
|
|
||||||
|
|
||||||
def test_migrate_config(tljh_dir):
|
def test_migrate_config(tljh_dir):
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
"""Test traefik configuration"""
|
"""Test traefik configuration"""
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import toml
|
|
||||||
import pytest
|
import pytest
|
||||||
|
import toml
|
||||||
|
|
||||||
from tljh import config
|
from tljh import config, traefik
|
||||||
from tljh import traefik
|
|
||||||
|
|
||||||
|
|
||||||
def test_download_traefik(tmpdir):
|
def test_download_traefik(tmpdir):
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
"""
|
"""
|
||||||
Test wrappers in tljw.user module
|
Test wrappers in tljw.user module
|
||||||
"""
|
"""
|
||||||
from tljh import user
|
import grp
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
|
import pwd
|
||||||
import stat
|
import stat
|
||||||
import uuid
|
import uuid
|
||||||
import pwd
|
|
||||||
import grp
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from tljh import user
|
||||||
|
|
||||||
|
|
||||||
def test_ensure_user():
|
def test_ensure_user():
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import pytest
|
|
||||||
from tljh import utils
|
|
||||||
import subprocess
|
|
||||||
import logging
|
import logging
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from tljh import utils
|
||||||
|
|
||||||
|
|
||||||
def test_run_subprocess_exception(mocker):
|
def test_run_subprocess_exception(mocker):
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Utilities for working with the apt package manager
|
|||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from tljh import utils
|
from tljh import utils
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
"""
|
"""
|
||||||
Wrap conda commandline program
|
Wrap conda commandline program
|
||||||
"""
|
"""
|
||||||
|
import contextlib
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import json
|
|
||||||
import hashlib
|
|
||||||
import contextlib
|
|
||||||
import logging
|
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
|||||||
@@ -13,18 +13,17 @@ tljh-config show firstlevel.second_level
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
from collections.abc import Sequence, Mapping
|
|
||||||
from copy import deepcopy
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
from collections.abc import Mapping, Sequence
|
||||||
|
from copy import deepcopy
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from .yaml import yaml
|
from .yaml import yaml
|
||||||
|
|
||||||
|
|
||||||
INSTALL_PREFIX = os.environ.get("TLJH_INSTALL_PREFIX", "/opt/tljh")
|
INSTALL_PREFIX = os.environ.get("TLJH_INSTALL_PREFIX", "/opt/tljh")
|
||||||
HUB_ENV_PREFIX = os.path.join(INSTALL_PREFIX, "hub")
|
HUB_ENV_PREFIX = os.path.join(INSTALL_PREFIX, "hub")
|
||||||
USER_ENV_PREFIX = os.path.join(INSTALL_PREFIX, "user")
|
USER_ENV_PREFIX = os.path.join(INSTALL_PREFIX, "user")
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ def tljh_extra_user_conda_packages():
|
|||||||
"""
|
"""
|
||||||
Return list of extra conda packages to install in user environment.
|
Return list of extra conda packages to install in user environment.
|
||||||
"""
|
"""
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
@hookspec
|
@hookspec
|
||||||
@@ -20,7 +19,6 @@ def tljh_extra_user_pip_packages():
|
|||||||
"""
|
"""
|
||||||
Return list of extra pip packages to install in user environment.
|
Return list of extra pip packages to install in user environment.
|
||||||
"""
|
"""
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
@hookspec
|
@hookspec
|
||||||
@@ -28,7 +26,6 @@ def tljh_extra_hub_pip_packages():
|
|||||||
"""
|
"""
|
||||||
Return list of extra pip packages to install in the hub environment.
|
Return list of extra pip packages to install in the hub environment.
|
||||||
"""
|
"""
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
@hookspec
|
@hookspec
|
||||||
@@ -38,7 +35,6 @@ def tljh_extra_apt_packages():
|
|||||||
|
|
||||||
These will be installed before additional pip or conda packages.
|
These will be installed before additional pip or conda packages.
|
||||||
"""
|
"""
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
@hookspec
|
@hookspec
|
||||||
@@ -49,7 +45,6 @@ def tljh_custom_jupyterhub_config(c):
|
|||||||
Anything you can put in `jupyterhub_config.py` can
|
Anything you can put in `jupyterhub_config.py` can
|
||||||
be here.
|
be here.
|
||||||
"""
|
"""
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
@hookspec
|
@hookspec
|
||||||
@@ -62,7 +57,6 @@ def tljh_config_post_install(config):
|
|||||||
be the serialized contents of config, so try to not
|
be the serialized contents of config, so try to not
|
||||||
overwrite anything the user might have explicitly set.
|
overwrite anything the user might have explicitly set.
|
||||||
"""
|
"""
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
@hookspec
|
@hookspec
|
||||||
@@ -73,7 +67,6 @@ def tljh_post_install():
|
|||||||
|
|
||||||
This can be arbitrary Python code.
|
This can be arbitrary Python code.
|
||||||
"""
|
"""
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
@hookspec
|
@hookspec
|
||||||
@@ -82,4 +75,3 @@ def tljh_new_user_create(username):
|
|||||||
Script to be executed after a new user has been added.
|
Script to be executed after a new user has been added.
|
||||||
This can be arbitrary Python code.
|
This can be arbitrary Python code.
|
||||||
"""
|
"""
|
||||||
pass
|
|
||||||
|
|||||||
@@ -17,15 +17,7 @@ import pluggy
|
|||||||
import requests
|
import requests
|
||||||
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
from requests.packages.urllib3.exceptions import InsecureRequestWarning
|
||||||
|
|
||||||
from tljh import (
|
from tljh import apt, conda, hooks, migrator, systemd, traefik, user
|
||||||
apt,
|
|
||||||
conda,
|
|
||||||
hooks,
|
|
||||||
migrator,
|
|
||||||
systemd,
|
|
||||||
traefik,
|
|
||||||
user,
|
|
||||||
)
|
|
||||||
|
|
||||||
from .config import (
|
from .config import (
|
||||||
CONFIG_DIR,
|
CONFIG_DIR,
|
||||||
@@ -518,7 +510,6 @@ def main():
|
|||||||
print("Progress page server stopped successfully.")
|
print("Progress page server stopped successfully.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Couldn't stop the progress page server. Exception was {e}.")
|
logger.error(f"Couldn't stop the progress page server. Exception was {e}.")
|
||||||
pass
|
|
||||||
|
|
||||||
ensure_jupyterhub_service(HUB_ENV_PREFIX)
|
ensure_jupyterhub_service(HUB_ENV_PREFIX)
|
||||||
ensure_jupyterhub_running()
|
ensure_jupyterhub_running()
|
||||||
|
|||||||
@@ -2,14 +2,15 @@
|
|||||||
JupyterHub config for the littlest jupyterhub.
|
JupyterHub config for the littlest jupyterhub.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from glob import glob
|
|
||||||
import os
|
import os
|
||||||
|
from glob import glob
|
||||||
|
|
||||||
|
from jupyterhub_traefik_proxy import TraefikTomlProxy
|
||||||
|
|
||||||
from tljh import configurer
|
from tljh import configurer
|
||||||
from tljh.config import INSTALL_PREFIX, USER_ENV_PREFIX, CONFIG_DIR
|
from tljh.config import CONFIG_DIR, INSTALL_PREFIX, USER_ENV_PREFIX
|
||||||
from tljh.utils import get_plugin_manager
|
|
||||||
from tljh.user_creating_spawner import UserCreatingSpawner
|
from tljh.user_creating_spawner import UserCreatingSpawner
|
||||||
from jupyterhub_traefik_proxy import TraefikTomlProxy
|
from tljh.utils import get_plugin_manager
|
||||||
|
|
||||||
c.JupyterHub.spawner_class = UserCreatingSpawner
|
c.JupyterHub.spawner_class = UserCreatingSpawner
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"""Setup tljh logging"""
|
"""Setup tljh logging"""
|
||||||
import os
|
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
|
||||||
from .config import INSTALL_PREFIX
|
from .config import INSTALL_PREFIX
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,11 @@
|
|||||||
"""Migration utilities for upgrading tljh"""
|
"""Migration utilities for upgrading tljh"""
|
||||||
|
|
||||||
import os
|
|
||||||
from datetime import date
|
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
from datetime import date
|
||||||
|
|
||||||
from tljh.config import (
|
from tljh.config import CONFIG_DIR, CONFIG_FILE, INSTALL_PREFIX
|
||||||
CONFIG_DIR,
|
|
||||||
CONFIG_FILE,
|
|
||||||
INSTALL_PREFIX,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger("tljh")
|
logger = logging.getLogger("tljh")
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ Wraps systemctl to install, uninstall, start & stop systemd services.
|
|||||||
|
|
||||||
If we use a debian package instead, we can get rid of all this code.
|
If we use a debian package instead, we can get rid of all this code.
|
||||||
"""
|
"""
|
||||||
import subprocess
|
|
||||||
import os
|
import os
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
def reload_daemon():
|
def reload_daemon():
|
||||||
|
|||||||
@@ -3,14 +3,15 @@ import hashlib
|
|||||||
import os
|
import os
|
||||||
from glob import glob
|
from glob import glob
|
||||||
|
|
||||||
from jinja2 import Template
|
|
||||||
from passlib.apache import HtpasswdFile
|
|
||||||
import backoff
|
import backoff
|
||||||
import requests
|
import requests
|
||||||
import toml
|
import toml
|
||||||
|
from jinja2 import Template
|
||||||
|
from passlib.apache import HtpasswdFile
|
||||||
|
|
||||||
|
from tljh.configurer import _merge_dictionaries, load_config
|
||||||
|
|
||||||
from .config import CONFIG_DIR
|
from .config import CONFIG_DIR
|
||||||
from tljh.configurer import load_config, _merge_dictionaries
|
|
||||||
|
|
||||||
# traefik 2.7.x is not supported yet, use v1.7.x for now
|
# traefik 2.7.x is not supported yet, use v1.7.x for now
|
||||||
# see: https://github.com/jupyterhub/traefik-proxy/issues/97
|
# see: https://github.com/jupyterhub/traefik-proxy/issues/97
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
from tljh.normalize import generate_system_username
|
|
||||||
from tljh import user
|
|
||||||
from tljh import configurer
|
|
||||||
from systemdspawner import SystemdSpawner
|
|
||||||
from traitlets import Dict, Unicode, List
|
|
||||||
from jupyterhub_configurator.mixins import ConfiguratorSpawnerMixin
|
from jupyterhub_configurator.mixins import ConfiguratorSpawnerMixin
|
||||||
|
from systemdspawner import SystemdSpawner
|
||||||
|
from traitlets import Dict, List, Unicode
|
||||||
|
|
||||||
|
from tljh import configurer, user
|
||||||
|
from tljh.normalize import generate_system_username
|
||||||
|
|
||||||
|
|
||||||
class CustomSpawner(SystemdSpawner):
|
class CustomSpawner(SystemdSpawner):
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
ensures the same yaml settings for reading/writing
|
ensures the same yaml settings for reading/writing
|
||||||
throughout tljh
|
throughout tljh
|
||||||
"""
|
"""
|
||||||
from ruamel.yaml.composer import Composer
|
|
||||||
from ruamel.yaml import YAML
|
from ruamel.yaml import YAML
|
||||||
|
from ruamel.yaml.composer import Composer
|
||||||
|
|
||||||
|
|
||||||
class _NoEmptyFlowComposer(Composer):
|
class _NoEmptyFlowComposer(Composer):
|
||||||
|
|||||||
Reference in New Issue
Block a user