File tree Expand file tree Collapse file tree 1 file changed +17
-8
lines changed Expand file tree Collapse file tree 1 file changed +17
-8
lines changed Original file line number Diff line number Diff line change 1- import asyncio
21import os
32import sys
43
87from jupyterhub .utils import random_port , url_path_join
98from jupyterhub .services .auth import HubAuth
109
11- from tornado . escape import json_encode
10+ import requests
1211
1312
1413def main (argv = None ):
@@ -17,12 +16,22 @@ def main(argv=None):
1716 hub_auth .client_ca = os .environ .get ("JUPYTERHUB_SSL_CLIENT_CA" , "" )
1817 hub_auth .certfile = os .environ .get ("JUPYTERHUB_SSL_CERTFILE" , "" )
1918 hub_auth .keyfile = os .environ .get ("JUPYTERHUB_SSL_KEYFILE" , "" )
20- asyncio .run (
21- hub_auth ._api_request (
22- method = "POST" ,
23- url = url_path_join (hub_auth .api_url , "batchspawner" ),
24- body = json_encode ({"port" : port }),
25- )
19+
20+ url = url_path_join (hub_auth .api_url , "batchspawner" )
21+ headers = {"Authorization" : f"token { hub_auth .api_token } " }
22+
23+ # internal_ssl kwargs
24+ kwargs = {}
25+ if hub_auth .certfile and hub_auth .keyfile :
26+ kwargs ["cert" ] = (hub_auth .certfile , hub_auth .keyfile )
27+ if hub_auth .client_ca :
28+ kwargs ["verify" ] = hub_auth .client_ca
29+
30+ r = requests .post (
31+ url ,
32+ headers = {"Authorization" : f"token { hub_auth .api_token } " },
33+ json = {"port" : port },
34+ ** kwargs ,
2635 )
2736
2837 cmd_path = which (sys .argv [1 ])
You can’t perform that action at this time.
0 commit comments