Skip to content

Commit

Permalink
Merge pull request #247 from ryanlovett/jupyterhub-3.0.0b1
Browse files Browse the repository at this point in the history
Quell async warning, and POST with body for jupyterhub 3.0
  • Loading branch information
mbmilligan authored Mar 1, 2023
2 parents c808003 + 75358f3 commit d5f9a0b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ repos:
# Lint: Checks that non-binary executables have a proper shebang.
- id: check-executables-have-shebangs


# pre-commit.ci config reference: https://pre-commit.ci/#configuration
ci:
autoupdate_schedule: monthly
20 changes: 17 additions & 3 deletions batchspawner/singleuser.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,31 @@
from jupyterhub.utils import random_port, url_path_join
from jupyterhub.services.auth import HubAuth

import requests


def main(argv=None):
port = random_port()
hub_auth = HubAuth()
hub_auth.client_ca = os.environ.get("JUPYTERHUB_SSL_CLIENT_CA", "")
hub_auth.certfile = os.environ.get("JUPYTERHUB_SSL_CERTFILE", "")
hub_auth.keyfile = os.environ.get("JUPYTERHUB_SSL_KEYFILE", "")
hub_auth._api_request(
method="POST",
url=url_path_join(hub_auth.api_url, "batchspawner"),

url = url_path_join(hub_auth.api_url, "batchspawner")
headers = {"Authorization": f"token {hub_auth.api_token}"}

# internal_ssl kwargs
kwargs = {}
if hub_auth.certfile and hub_auth.keyfile:
kwargs["cert"] = (hub_auth.certfile, hub_auth.keyfile)
if hub_auth.client_ca:
kwargs["verify"] = hub_auth.client_ca

r = requests.post(
url,
headers={"Authorization": f"token {hub_auth.api_token}"},
json={"port": port},
**kwargs,
)

cmd_path = which(sys.argv[1])
Expand Down

0 comments on commit d5f9a0b

Please sign in to comment.