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
2
1
import os
3
2
import sys
4
3
8
7
from jupyterhub .utils import random_port , url_path_join
9
8
from jupyterhub .services .auth import HubAuth
10
9
11
- from tornado . escape import json_encode
10
+ import requests
12
11
13
12
14
13
def main (argv = None ):
@@ -17,12 +16,22 @@ def main(argv=None):
17
16
hub_auth .client_ca = os .environ .get ("JUPYTERHUB_SSL_CLIENT_CA" , "" )
18
17
hub_auth .certfile = os .environ .get ("JUPYTERHUB_SSL_CERTFILE" , "" )
19
18
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 ,
26
35
)
27
36
28
37
cmd_path = which (sys .argv [1 ])
You can’t perform that action at this time.
0 commit comments